Michael Solomon
Michael Solomon
@sam-super, I think Jest contributes to this by creating a test sandbox. It may wipe out `globalThis` but not the module cache.
@kettanaito I investigated this. I'm pretty sure it's because `jest` reset all modules except the builtin modules.
> 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 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 for all test...
Interesting... I found that the following also fixes it: ```js -import nock, {disableNetConnect} from 'nock'; +import nock from 'nock'; import {httpRequest} from "../request"; nock.disableNetConnect(); ... ```
@sam-super I use `jest` extensively and haven't encountered this problem, yet. Do you have something special in your `jest` environment/config? Are you using typescript?
@sadams @sam-super [It's working for me](https://github.com/nock/nock/issues/2802#issuecomment-2578695662) now. I can reproduce this only with `--no-cache` AND put console.log in one of the test files. It's the same for you?
I'm not familiar with Bun and have other priorities right now. PR/Fix is welcome
@marikaner In order to keep this issue clean, I opened an issue in `nock` to track this and discuss about workaround (https://github.com/nock/nock/issues/2789)
Sure! I'd love to contribute to this one... I'm looking into it.