Skip to content

Vitest fails in stackblitz but runs locally #3481

Description

@vezaynk

Description of Bug

Provide a concise description of your bug and your project link (if applicable).

My project has a failing test with vitest when running stackblitz, but not locally. Very strange!

Steps to Reproduce

  1. Go to https://stackblitz.com/edit/vitejs-vite-vs3tf6js
  2. Run npx vitest
  3. See it fail

Download, repeat locally, see it pass

Expected Behavior

A clear and concise description of what you expected to happen.

Tests should pass in stackblitz

Screenshots/Screencast

If applicable, add screenshots to help explain your problem.

❯ npx vitest

 DEV  v3.2.4 /home/projects/vitejs-vite-vs3tf6js

 ❯ packages/ui/src/index.test.ts (1 test | 1 failed) 2ms
   × My tests > Passes 1ms
     → vi.mocked(...).mockReturnValueOnce is not a function

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  packages/ui/src/index.test.ts > My tests > Passes
TypeError: vi.mocked(...).mockReturnValueOnce is not a function
 ❯ file:/home/projects/vitejs-vite-vs3tf6js/packages/ui/src/index.test.ts#cjs:8:61
 ❯ _0xec62f6/< ../../../blitz.96435430.js:31:27890
 ❯ _0xec62f6 ../../../blitz.96435430.js:31:27849

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯


 Test Files  1 failed (1)
      Tests  1 failed (1)
   Start at  13:35:48
   Duration  1.47s (transform 214ms, setup 0ms, collect 211ms, tests 2ms, environment 0ms, prepare 334ms)

 FAIL  Tests failed. Watching for file changes...
       press h to show help, press q to quit
 

Additional Context/Questions
Add any other context or questions regarding this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions