BUG: web test runner plugin 'Failed to dynamically import module' when tests are not in src directory
Author: PindaPixelCreated Oct 30, 2021Updated May 27, 2023
Quick checklist
- I am using the latest version of Snowpack and all plugins.
What package manager are you using?
yarn berry
What operating system are you using?
Windows
Describe the bug
I cannot get web-test-runner to get to work and I'm not sure where the fault lies. I've seen issues with the same error in the web-test-runner repo, but those are supposedly fixed.
Steps to reproduce
yarn create snowpack-appusing template@snowpack/react-typescriptyarn set version berry-> delete node_modules ->yarn install- Change the test script in package.json from
web-test-runner \"src/**/*.test.tsx\"toweb-test-runner \"tests/**/*.test.{ts,tsx}\" - For vscode:
yarn dlx @yarnpkg/sdks vscode- Command pallet:
TypeScript: Select TypeScript version-> use workspace version.
- Create a test:
// tests/test.test.tsx
import { assert } from 'chai';
describe('Test test', () => {
it('Does a test!', () => {
assert.equal(1, 1);
});
});- yarn test
- This should happen:
$ yarn test
[snowpack] starting server...
[12:55:54] [snowpack] Ready!
[12:55:54] [snowpack] Server started in 33ms.
[12:55:54] [snowpack] Local: http://localhost:8080
[12:55:54] [snowpack] Network: http://...:8080
[12:55:54] [snowpack] watching for file changes...
[12:55:55] [@snowpack/plugin-typescript]
[12:55:55] [@snowpack/plugin-typescript] 11:54:55 AM - Starting compilation in watch mode...
tests\test.test.tsx:
Browser logs:
TypeError: Failed to fetch dynamically imported module: http://localhost:8000/tests/test.test.tsx?wtr-session-id=v7oWSrQQbvgJFuIoqzsJT
❌ Could not import your test module. Check the browser logs or open the browser in debug mode for more information.
Chrome: |██████████████████████████████| 1/1 test files | 0 passed, 0 failed
Error while running tests.Link to minimal reproducible example (optional)
No response
Source: FredKSchott/snowpack