Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: Vitest __mocks__ not working when using @cloudflare/vitest-pool-workers #7679

Open
saitolume opened this issue Jan 6, 2025 · 0 comments
Labels
bug Something that isn't working vitest Relating to the Workers Vitest integration

Comments

@saitolume
Copy link

Which Cloudflare product(s) does this pertain to?

Workers Vitest Integration

What versions are you using?

2.1.8 [vitest], 0.5.40 [@cloudflare/vitest-pool-workers]

What operating system and version are you using?

macIS Sequoia 15.1.1

Please provide a link to a minimal reproduction

https://github.com/saitolume/workers-sdk-bug-report

Describe the Bug

When using @cloudflare/vitest-pool-workers, the mocks defined in Vitest's __mocks__ directory do not work as expected.

  • Expected behavior:
    Modules defined in the __mocks__ directory should automatically be used as mocks.
  • Actual behavior:
    When using @cloudflare/vitest-pool-workers, the modules in __mocks__ are not applied. Instead, Vitest's default mocking behavior is used.

Please provide any relevant error logs

pnpm run test:fail                                                                                                                                                                                                                                                                                                                                                        

> @ test:fail /workers-sdk-bug-report
> vitest run --config vitest.fail.config.ts


 RUN  v2.1.8 /workers-sdk-bug-report

[vpw:inf] Starting isolated runtimes for vitest.fail.config.ts...
 ❯ index.test.ts (1)
   × uuid

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

 FAIL  index.test.ts > uuid
AssertionError: expected undefined to be 'expected' // Object.is equality

- Expected: 
"expected"

+ Received: 
undefined

 ❯ index.test.ts:7:16
      5| 
      6| test('uuid', () => {
      7|   expect(v4()).toBe('expected')
       |                ^
      8| })
      9| 

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

 Test Files  1 failed (1)
      Tests  1 failed (1)
   Start at  00:51:16
   Duration  1.04s (transform 10ms, setup 0ms, collect 25ms, tests 6ms, environment 1ms, prepare 107ms)

[vpw:dbg] Shutting down runtimes...
 ELIFECYCLE  Command failed with exit code 1.
@saitolume saitolume added the bug Something that isn't working label Jan 6, 2025
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jan 6, 2025
@edmundhung edmundhung added the vitest Relating to the Workers Vitest integration label Jan 6, 2025
@edmundhung edmundhung moved this from Untriaged to Backlog in workers-sdk Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working vitest Relating to the Workers Vitest integration
Projects
Status: Backlog
Development

No branches or pull requests

2 participants