kit icon indicating copy to clipboard operation
kit copied to clipboard

Test files outside src fail to load Svelte files

Open seanlail opened this issue 1 year ago • 1 comments

Describe the bug

When I use the typescript.config option to change the path of the tests folder to a folder in my root the Svelte files I have used in this tests fail to load.

This is for tests that use a Svelte wrapper file. I need these wrapper files to setup slot tests.

Reproduction

https://github.com/seanlail/kit-issue-tests

There are 2 commits:

  1. Sets up the tests inside the src folder and the svelte imports work (test passes)
  2. Moved the tests folder outside of src. (test fails)

Logs

FAIL  __tests__/+layout.test.ts [ __tests__/+layout.test.ts ]
Error: Failed to load url /__tests__/LayoutWrapper.svelte (resolved id: /Users/seanlail/kit-issue-tests/__tests__/LayoutWrapper.svelte) in /Users/seanlail/kit-issue-tests/__tests__/+layout.test.ts. Does the file exist?
 ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-ca21228b.js:39470:21

System Info

  System:
    OS: macOS 13.1
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 95.64 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node
    npm: 9.3.1 - ~/.nvm/versions/node/v18.14.0/bin/npm
  Browsers:
    Chrome: 113.0.5672.126
    Firefox: 99.0.1
    Safari: 16.2
  npmPackages:
    @sveltejs/adapter-node: 1.2.4 => 1.2.4 
    @sveltejs/kit: 1.18.0 => 1.18.0 
    svelte: 3.59.1 => 3.59.1 
    vite: 4.3.7 => 4.3.7 

Severity

serious, but I can work around it (I have to ignore the tests that are failing)

Additional Information

I thought this may be a Vitest / Vite issue, but it's part of the Kit setup that we can change the folder for the tests, so I think it's valid to create the issue here.

seanlail avatar Feb 25 '23 14:02 seanlail

I just updated the dependencies to latest (to see if anything had changed) and the issue still exists.

seanlail avatar May 18 '23 08:05 seanlail

https://github.com/vitest-dev/vitest/issues/3953#issuecomment-1679134767

seanlail avatar Aug 24 '23 12:08 seanlail

Closing this as it's fixed without any changes in Vitest 0.34.2

seanlail avatar Aug 24 '23 13:08 seanlail