Skip to content
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

Regression (0.33.0 -> 0.34.0) tests completely break when using jsdom or happy-dom with SvelteKit #3953

Closed
6 tasks done
LorenzoBloedow opened this issue Aug 14, 2023 · 5 comments · Fixed by #3956
Closed
6 tasks done

Comments

@LorenzoBloedow
Copy link
Contributor

Describe the bug

So basically after updating to 0.34.0 from 0.33.0 I get the following error message (redacted):

Error: Failed to load url [REDACTED]/tests/unit/DarkModeSwitch.test.ts (resolved id: [REDACTED]/tests/unit/DarkModeSwitch.test.ts). Does the file exist?

Contrary to what the error message suggests, the file does exist.
I believe this is due to #3491 as it does work when using node instead of jsdom or happy-dom, suggesting the use of the web transform mode instead of ssr is what's causing this.

Note: 0.34.1 doesn't fix the issue.

Reproduction

Open the following StackBlitz and run npm run test
https://stackblitz.com/edit/sveltejs-kit-template-default-fwbgpv

System Info

System:
  OS: Linux 5.0 undefined
  CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Memory: 0 Bytes / 0 Bytes
  Shell: 1.0 - /bin/jsh
Binaries:
  Node: 16.20.0 - /usr/local/bin/node
  Yarn: 1.22.19 - /usr/local/bin/yarn
  npm: 9.4.2 - /usr/local/bin/npm
  pnpm: 8.6.10 - /usr/local/bin/pnpm
npmPackages:
  vite: ^4.4.2 => 4.4.9 
  vitest: ^0.34.1 => 0.34.1

Used Package Manager

npm

Validations

@stackblitz
Copy link

stackblitz bot commented Aug 14, 2023

@sheremet-va
Copy link
Member

File is outside root. Try disabling server.fs.strict.

@sheremet-va
Copy link
Member

File is outside root. Try disabling server.fs.strict.

Indeed the problem is with this. While we are working on fixing this, you can disable strict in test mode or add a tests folder to server.fs.allow

@LorenzoBloedow
Copy link
Contributor Author

Thank you.
I was under the impression the root directory was where the configuration file lives.

As you suggested, adding the following to vite.config.ts fixes the problem:

server: {
  fs: {
    allow: [".."]
  }
}

@sheremet-va
Copy link
Member

I was under the impression the root directory was where the configuration file lives.

Svelte does some magic to fs.allow values, so the root is not included. In the next Vitest version we populate fs.allow ourselves.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants