-
-
Notifications
You must be signed in to change notification settings - Fork 525
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
feat!: adopt the global Fetch API #1436
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 90b854a:
|
61af97f
to
547eecb
Compare
@weyert shouldn't be a problem since you can override the |
@kettanaito @luchsamapparat @dbritto-dev I went into the inner workings of Node.js to figure out why this error occurs in JSDOM environments and how we can prevent it to solve it for real, not just the symptoms. I found a rather simple solution that I have implemented in in PR #1779. |
…s from "setMaxListeners" in jsdom (#1779) Co-authored-by: Artem Zakharchenko <[email protected]>
📦
|
@thepassle, absolutely agree and absolutely welcome a pull request! 🙏 |
Co-authored-by: Artem Zakharchenko <[email protected]>
|
I've spent some time yesterday migrating away about a thousand handlers to the new fetch API (currently on the fresh BUT, I've been stuck all day on some failing tests using the new API. Not a lot though, which was surprising, and it turns out tests that fail are the ones that used I'm NOT saying all The current v1 docs state the following about one-time overrides:
There's also this code block, which states that the first matching request will receive the mocked response: rest.get('/book/:bookId', (req, res, ctx) => {
// The first matching "GET /book/:bookId" request
// will receive this mocked response.
return res.once(
ctx.status(500),
ctx.json({ message: 'Internal server error' }),
)
}) I've created a quick reproduction here: https://stackblitz.com/edit/vitest-dev-vitest-xa3evs?file=test%2Fbasic.test.ts&view=editor. The test is green since I wanted to validate what I'm saying. Since the configured Can you confirm this is a bug, and not a change in behavior expected in v2? Since I couldn't find any information about such a change, and since it would be extremely breaking for people who can't intertwine individual requests and |
Thanks for reporting this, @acidoxee.
I confirm this is a bug. I will do my best to address it but it may be after the 2.0 release. Please, could you open a new issue about it? Thanks. |
Here you go @kettanaito: #1782. Thanks a lot for all your hard work! 🙏 |
Yes, I totally agree I could use different environment depending on the need. Only I never have been able to get the I haven't gotten it working yet in my unit tests in Jest for Next.js against newer than r20 versions. Wondering if I need to rewrite my tests or something 🤔 Everything is timing out in r24. I will play around tomorrow. I was thinking of switching to Vitest but not sure if that's a good idea compared to |
@weyert are you using jest or vitest? |
🎉 |
Released: v2.0.0 🎉This has been released in v2.0.0! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
### What? This bumps the supported `msw` version when using the `playwright` test mode. There's no need for mocking requests and responses anymore since [they adopted](mswjs/msw#1436) the global fetch API in `msw`. ### Why? Users can extend `test` from `playwright` manually and create the `msw` fixtures, but it's better if it works out of the box with newer versions of `msw`. Fixes #63338. Co-authored-by: Sam Ko <[email protected]>
### What? This bumps the supported `msw` version when using the `playwright` test mode. There's no need for mocking requests and responses anymore since [they adopted](mswjs/msw#1436) the global fetch API in `msw`. ### Why? Users can extend `test` from `playwright` manually and create the `msw` fixtures, but it's better if it works out of the box with newer versions of `msw`. Fixes #63338. Co-authored-by: Sam Ko <[email protected]>
MockedRequest.body
and cleanup #1318 since it's no longer relevant (noMockedRequest
)msw/node
don't work with modern node16-style module resolution #1427Migration guide
Roadmap
RequestWithCredentials
internal interceptors#329@mswjs/interceptors
msw
fails)ReadableStream
as the mocked response body (internally: read/send request/response bodies as streams)test/rest-api/cookies-inheritance.node.test.ts
ambiguous response body typerequest.formData()
test (see NotSupportedError: multipart/form-data not supported nodejs/undici#1979). Just updating to the latest Node 18 will fix this.request.clone()
:serializeResponse
:xhr.onload
being called twice (XMLHttpRequest: "onload" is called twice interceptors#359)SetupWorkerApi
in Node.js module to extendwindow
when working with Playwright.req.operationName
(feat: addoperationName
to GraphQL request #1568)statuses
import must beassert { type: 'json' }
but that gets stripped off during the build. Find the way to keep it or check itstatuses
exports a plain object.@open-draft/logger
installation issue with PNPM.cookie
graphql@16
accessingprocess
in the browser (check "globalThis.process" before accessing it graphql/graphql-js#3887)..printHandlers()
by.listHandlers()
.graphql.operation()
test(graphql): add test on anonymous operation warning #1693Math.random()
withcrypto.randomUUID()
#1762