Giter VIP home page Giter VIP logo

Comments (13)

thebjorn avatar thebjorn commented on August 16, 2024

`"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.

AriPerkkio avatar AriPerkkio commented on August 16, 2024

How do I reproduce this error? Works fine here https://stackblitz.com/github/thebjorn/vitest-problems?file=src%2Ftest-sum.js

image

from vitest.

AriPerkkio avatar AriPerkkio commented on August 16, 2024

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.

thebjorn avatar thebjorn commented on August 16, 2024

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.

AriPerkkio avatar AriPerkkio commented on August 16, 2024

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.

thebjorn avatar thebjorn commented on August 16, 2024

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.

AriPerkkio avatar AriPerkkio commented on August 16, 2024

(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.

thebjorn avatar thebjorn commented on August 16, 2024

same result.

from vitest.

AriPerkkio avatar AriPerkkio commented on August 16, 2024

I'm unable to reproduce this issue on Github Codespaces or Stackblitz. It works fine all the time.

from vitest.

thebjorn avatar thebjorn commented on August 16, 2024

Hmm... just for fun I tried using pnpm instead of yarn and that worked...(?)

from vitest.

thebjorn avatar thebjorn commented on August 16, 2024

Neither npm nor yarn works.

from vitest.

AriPerkkio avatar AriPerkkio commented on August 16, 2024

Both NPM and Yarn work in Github Codespaces using your reproduction setup. I have no idea how to reproduce this issue. 🤷

from vitest.

github-actions avatar github-actions commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.