Sam Adams

Results 28 comments of Sam Adams

Not sure why but some tests failed when running locally on macos (node 18). they all seem to be due to header being lowercase on my machine: any idea why?

> How does the code pass the check [for an already applied interceptor](https://github.com/mswjs/interceptors/blob/main/src/Interceptor.ts#L82)? It seems like this is the problem we need to solve. I'm doing some more digging, but...

@mikicho yup just tested it and `globalThis` is reset between each test. I guess it's then `node` env: https://github.com/jestjs/jest/blob/main/packages/jest-environment-node/src/index.ts

So MSW's attempt to use `globalThis` to maintain a single instance of each interceptor wont work in jest via nodejs. Because the `FetchInterceptor` is bound to `globalFetch`, it currently behaves...

> > Have you found the reasoning behind this behavior? > > It's `jest` feature to isolate tests between files in `runInBand` mode. I haven't needed to set `runInBand` to...

@mikicho @kettanaito this is a repo i put together to demonstrate how jest resets global state and how the proxy MSW creates persists regardless: https://github.com/sam-super/msw-proxy-bug

> > I haven't needed to set runInBand to cause this issue. > > You run [one worker](https://github.com/sam-super/msw-proxy-bug/blob/main/jest.config.js#L6), it's practically the same. in both cases, `jest` has only one process...

I didn't think the example repo (https://github.com/sam-super/msw-proxy-bug) was clear enough in what it was doing (due to the tests passing). I updated it so the tests fail in an attempted...

@kettanaito given my above PR showing that globalThis is wiped out by jest (by default on nodejs), and considering MSW doesn't support jest, is it even worth me adding a...

still a problem in `14.0.0-beta.17`