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

Vitest 1.0.2 broke happy-dom with msw + axios #4730

Closed
6 tasks done
marioleed opened this issue Dec 11, 2023 · 3 comments
Closed
6 tasks done

Vitest 1.0.2 broke happy-dom with msw + axios #4730

marioleed opened this issue Dec 11, 2023 · 3 comments
Labels

Comments

@marioleed
Copy link

Describe the bug

I upgraded vitest to latest version, 1.0.2, and my tests using msw started to crash with the following message:

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: response.body.getReader is not a function
❯ XMLHttpRequestController.respondWith node_modules/.pnpm/@mswjs+interceptors@0.25.13/node_modules/@mswjs/interceptors/lib/node/chunk-V3QPQ45S.mjs:452:36
❯ xhrRequestController.onRequest node_modules/.pnpm/@mswjs+interceptors@0.25.13/node_modules/@mswjs/interceptors/lib/node/chunk-V3QPQ45S.mjs:727:39

This error originated in "tests/tests.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "request is ok". It might mean one of the following:

  • The error was thrown, while Vitest was running this test.
  • This was the last recorded test before the error was thrown, if error originated after test finished its execution.
    ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Same error using latest version 1.0.4.

It seems to have something to do with #4671.
Also mswjs/msw#1816 seems to be similar.

Reproduction

https://stackblitz.com/edit/vitejs-vite-wlzbz8?view=editor

Try it with vitest 1.0.1 - ✅ works
Try it with vitest >1.0.2 - ❌ breaks

System Info

Latest package versions (though vitest breaks from 1.0.2).

My local environment:

  System:
    OS: macOS 14.1.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 1.51 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.4.0 - /opt/homebrew/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.2.5 - /opt/homebrew/bin/npm
    pnpm: 8.12.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Brave Browser: 120.1.61.100
    Chrome: 119.0.6045.159
    Safari: 17.1.2
  npmPackages:
    @vitejs/plugin-basic-ssl: 1.0.2 => 1.0.2 
    @vitejs/plugin-react: 4.2.1 => 4.2.1 
    @vitest/coverage-v8: 1.0.4 => 1.0.4 
    vite: 5.0.7 => 5.0.7 
    vitest: 1.0.4 => 1.0.4

Used Package Manager

pnpm

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Dec 11, 2023

This happens because Vitest now respects happy-dom's Request and Response, and happy-dom uses Node.js Readable stream for a body. This class doesn't support getReader method.

I'd say this is an error on happy-dom side and not Vitest.

@marioleed
Copy link
Author

Ok, I'll open an issue at happy-dom. Thanks.

@sheremet-va
Copy link
Member

I am closing the issue here since Vitest cannot do anything to resolve this unless happy-dom implements the correct API.

@sheremet-va sheremet-va closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants