Skip to content

v4: Vitest component tests crash on switch to svelte4 #8698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cesarnml opened this issue Jun 5, 2023 · 4 comments
Closed

v4: Vitest component tests crash on switch to svelte4 #8698

cesarnml opened this issue Jun 5, 2023 · 4 comments

Comments

@cesarnml
Copy link
Contributor

cesarnml commented Jun 5, 2023

Describe the bug

Vitest test crash upon upgrading to svelte4.

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/@[email protected][email protected]/node_modules/svelte/package.json
 ❯ Object.<anonymous> node_modules/.pnpm/@[email protected][email protected]/node_modules/@testing-library/svelte/dist/pure.js:28:15

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


### System Info

```shell
System:
    OS: macOS 13.4
    CPU: (8) arm64 Apple M1
    Memory: 84.80 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
    Watchman: 2023.05.22.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 114.1.52.117
    Chrome: 113.0.5672.126
    Chrome Canary: 116.0.5813.0
    Firefox: 101.0
    Firefox Developer Edition: 114.0
    Firefox Nightly: 111.0a1
    Safari: 16.5
  npmPackages:
    svelte: 4.0.0-next.0 => 4.0.0-next.0

Severity

blocking all usage of svelte

@cesarnml cesarnml changed the title v4: Vitest component tests crash upon switching to svelte4 v4: Vitest component tests crash on switch to svelte4 Jun 6, 2023
@benmccann
Copy link
Member

This looks to me like an issue with the way @testing-library/svelte is distributed. 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

Can you file the issue there?

@benmccann benmccann added this to the 4.x milestone Jun 6, 2023
@cesarnml
Copy link
Contributor Author

cesarnml commented Jun 6, 2023

@yanick
Copy link

yanick commented Jun 6, 2023

Looking into it!

@benmccann
Copy link
Member

I'm going to go ahead and close this since it looks like it'll be fixed by testing-library/svelte-testing-library#221 and there's not much to do in this repository. I'll be happy to reopen this if it turns out there is something we need to do here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants