Comments (13)
`"vitest": "^0.9.0" works, but "^1.0.0" does not... At this point I can't tell if I'm doing something wrong (I haven't done anything special, so I don't think so..) or if the docs just haven't been updated to a new syntax? (it's literally the first example in the docs, so that too seems unlikely...?)
from vitest.
How do I reproduce this error? Works fine here https://stackblitz.com/github/thebjorn/vitest-problems?file=src%2Ftest-sum.js
from vitest.
modified
vite.config.js
to look for test files in jest format
(aside: the nice thing about jest is that it just worked..)
This is intentional #3530. Considering files like test/test-utils.ts
as test files is not ideal.
from vitest.
How do I reproduce this error?
(dev310) go|c:\srv\tmp> git clone https://github.com/thebjorn/vitest-problems
Cloning into 'vitest-problems'...
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 21 (delta 0), reused 21 (delta 0), pack-reused 0
Receiving objects: 100% (21/21), 31.64 KiB | 675.00 KiB/s, done.
(dev310) go|c:\srv\tmp> cd vitest-problems
(dev310) go|c:\srv\tmp\vitest-problems> node --version
v21.4.0
(dev310) go|c:\srv\tmp\vitest-problems> yarn --version
1.22.21
(dev310) go|c:\srv\tmp\vitest-problems> yarn
yarn install v1.22.21
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@sveltejs/vite-plugin-svelte > [email protected]" has incorrect peer dependency "svelte@^3.19.0 || ^4.0.0".
warning " > @vitest/[email protected]" has incorrect peer dependency "vitest@>=0.30.0 <1".
[4/4] Building fresh packages...
Done in 1.48s.
(dev310) go|c:\srv\tmp\vitest-problems> npx vitest --run
8:30:51 AM [vite-plugin-svelte] Your are using Svelte 5.0.0-next.80. Svelte 5 support is experimental, breaking changes can occur in any release until this notice is removed.
work in progress:
- svelte-inspector is disabled until dev mode implements node to code mapping
- hmr for .svelte files is disabled until hmr api is implemented
RUN v1.4.0 c:/srv/tmp/vitest-problems
❯ src/test-sum.js (0)
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
FAIL src/test-sum.js [ src/test-sum.js ]
TypeError: Cannot read properties of undefined (reading 'test')
❯ src/test-sum.js:3:1
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files 1 failed (1)
Tests no tests
Start at 08:30:51
Duration 441ms (transform 15ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 123ms)
(dev310) go|c:\srv\tmp\vitest-problems> yarn add -D [email protected]
yarn add v1.22.21
[1/4] Resolving packages...
⠁ (node:19480) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@sveltejs/vite-plugin-svelte > [email protected]" has incorrect peer dependency "svelte@^3.19.0 || ^4.0.0".
warning " > @vitest/[email protected]" has incorrect peer dependency "vitest@>=0.30.0 <1".
warning " > @vitest/[email protected]" has incorrect peer dependency "[email protected]".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 14 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ @types/[email protected]
├─ @types/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 1.53s.
(dev310) go|c:\srv\tmp\vitest-problems> npx vitest --run
RUN v0.9.4 c:/srv/tmp/vitest-problems
8:31:20 AM [vite-plugin-svelte] Your are using Svelte 5.0.0-next.80. Svelte 5 support is experimental, breaking changes can occur in any release until this notice is removed.
work in progress:
- svelte-inspector is disabled until dev mode implements node to code mapping
- hmr for .svelte files is disabled until hmr api is implemented
√ src/test-sum.js (1)
Test Files 1 passed (1)
Tests 1 passed (1)
Time 1.39s (in thread 1ms, 139434.73%)
(dev310) go|c:\srv\tmp\vitest-problems>
modified vite.config.js to look for test files in jest format
(aside: the nice thing about jest is that it just worked..)This is intentional #3530. Considering files like test/test-utils.ts as test files is not ideal.
That is certainly one opinion (although why you wouldn't simply call it test/utils.js
is a mystery), but for some of us api-stability, backwards compatibility, and compatibility with other languages' testing tools is more important - I realize this isn't true for everyone.
from vitest.
Start by resolving these issues that your package manager is warning about. These are likely pulling multiple version of Vitest into your setup.
(dev310) go|c:\srv\tmp\vitest-problems> yarn
yarn install v1.22.21
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@sveltejs/vite-plugin-svelte > [email protected]" has incorrect peer dependency "svelte@^3.19.0 || ^4.0.0".
warning " > @vitest/[email protected]" has incorrect peer dependency "vitest@>=0.30.0 <1".
[4/4] Building fresh packages...
Done in 1.48s.
from vitest.
I'm still getting the error after removing the two coverage packages:
(dev310) go|c:\srv\tmp\vitest-problems> rm -rf node_modules yarn.lock
(dev310) go|c:\srv\tmp\vitest-problems> yarn
yarn install v1.22.21
info No lockfile found.
[1/4] Resolving packages...
⠁ (node:55724) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@sveltejs/vite-plugin-svelte > [email protected]" has incorrect peer dependency "svelte@^3.19.0 || ^4.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 6.94s.
(dev310) go|c:\srv\tmp\vitest-problems> npx vitest --run
9:20:18 AM [vite-plugin-svelte] Your are using Svelte 5.0.0-next.80. Svelte 5 support is experimental, breaking changes can occur in any release until this notice is removed.
work in progress:
- svelte-inspector is disabled until dev mode implements node to code mapping
- hmr for .svelte files is disabled until hmr api is implemented
RUN v1.4.0 c:/srv/tmp/vitest-problems
❯ src/test-sum.js (0)
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
FAIL src/test-sum.js [ src/test-sum.js ]
TypeError: Cannot read properties of undefined (reading 'test')
❯ src/test-sum.js:3:1
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files 1 failed (1)
Tests no tests
Start at 09:20:18
Duration 666ms (transform 22ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 158ms)
Another developer here has verified that they get the problem.
Interestingly, I do not see the problem when running under wsl, nor when running under windows-latest on github...(?)
from vitest.
(dev310) go|c:\srv\tmp\vitest-problems> npx vitest --run
Could you also try if running vitest
through package.json
scripts help? I guess npx
could use another version if it's available as global package. So instead of npx vitest --run
use yarn test
.
from vitest.
same result.
from vitest.
I'm unable to reproduce this issue on Github Codespaces or Stackblitz. It works fine all the time.
from vitest.
Hmm... just for fun I tried using pnpm instead of yarn and that worked...(?)
from vitest.
Neither npm nor yarn works.
from vitest.
Both NPM and Yarn work in Github Codespaces using your reproduction setup. I have no idea how to reproduce this issue. 🤷
from vitest.
Hello @thebjorn. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction
will be closed if they have no activity within 3 days.
from vitest.
Related Issues (20)
- Pass down context to `onTestFinished` and `onTestFailed` instead of test result
- Some coverage.exclude glob patterns not matching for vitest 2 workspace HOT 4
- TypeError: Unknown file extension ".css"
- `tsc` with `"vitest"` version 2 requires `"@types/node"` to run without errors HOT 2
- Add 'coverageLinkUrl' option in Vitest UI for custom coverage report links
- Improve Vitest Public API
- Browser docs refer to defineCommand function which doesn't exist
- False negative with typecheck enabled HOT 4
- (v2) `Error: Failed to load url` when dynamic importing js files generated during tests with relative path HOT 4
- Istanbul: Coverage ignore doesn't work for default in switch HOT 3
- Type error on mockImplementation with call signature in object type HOT 3
- Vitest failing to bundle nested dependency while Vite succeeds HOT 2
- Scoped Fixtures HOT 2
- Vitest v2 reports zero coverage for types-only TypeScript files HOT 7
- Vitest v2 coverage is reporting 'Unexpected reserved word' error HOT 4
- [@vitest/web-worker] Cannot acces the crypto API from vitest web worker HOT 1
- Coverage report does not include types-only TS files HOT 1
- Global coverage threshold should not exclude glob based thresholds HOT 1
- Support 100 shorthand option for pattern based coverage rules HOT 1
- Istanbul failing to report coverage for CJS requires HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vitest.