testing-library / svelte-testing-library

:chipmunk: Simple and complete Svelte DOM testing utilities that encourage good testing practices
https://testing-library.com/docs/svelte-testing-library/intro
MIT License
615 stars 33 forks source link

Module distribution incompatible with upcoming svelte4 release #220

Closed cesarnml closed 1 year ago

cesarnml commented 1 year ago

Describe the bug

@testing-library/svelte tests crash on upgrading to [svelte4].(https://www.npmjs.com/package/svelte/v/4.0.0-next.0).

Reproduction

Minimal Example Repo: https://github.com/cesarnml/svelte4-testing-example

  1. Git clone above repo.
  2. pnpm i
  3. pnpm test:unit

Logs

FAIL  src/routes/page.spec.ts [ src/routes/page.spec.ts ]
Error: No "exports" main defined in /Users/cesar/code/svelte4-testing-example/node_modules/.pnpm/@testing-library+svelte@3.2.2_svelte@4.0.0-next.0/node_modules/svelte/package.json
 ❯ Object.<anonymous> node_modules/.pnpm/@testing-library+svelte@3.2.2_svelte@4.0.0-next.0/node_modules/@testing-library/svelte/dist/pure.js:28:15

Serialized Error: {
  "code": "ERR_PACKAGE_PATH_NOT_EXPORTED",
}

Recommendation:

My recommendation would be that they remove the babel build step which should not be necessary and add "type": "module". Given that its for testing Svelte libraries, they should only need an ESM version and probably shouldn't be distributing it as CJS @benmccann

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: