oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.37k stars 2.78k forks source link

nock does't work in bun #8781

Open panva opened 9 months ago

panva commented 9 months ago

What version of Bun is running?

1.0.26+c75e768a6

What platform is your computer?

No response

What steps can reproduce the bug?

gh repo clone nock/nock
cd nock
bun install
bun run ./node_modules/.bin/mocha --recursive tests

What is the expected behavior?

The nock test suite passes, indicating that nock can be used in project test suites to check if they work in bun or not.

What do you see instead?

Additional information

It is impossible for modules that have existing test suite for the Node.js runtime to test and assert their module works in Bun if the test suite doesn't even run in Bun. nock is a very common library for mocking http responses for the node:http and node:https modules.

JulianKingman commented 7 months ago

In version 1.0.4, I got this error: https://github.com/oven-sh/bun/issues/5006

Now in version 1.1.0, I get this error:

96 |     req.path = options.path
         ^
TypeError: Attempted to assign to readonly property.
      at attachToReq (/Users/Julian/Projects//node_modules/nock/lib/intercepted_request_router.js:96:5)
      at new InterceptedRequestRouter (/Users/Julian/Projects//node_modules/nock/lib/intercepted_request_router.js:73:5)
      at new OverriddenClientRequest (/Users/Julian/Projects//node_modules/nock/lib/intercept.js:290:25)
      at /Users/Julian/Projects//node_modules/nock/lib/intercept.js:426:14
      at /Users/Julian/Projects//node_modules/nock/lib/common.js:91:14
      at /Users/Julian/Projects//node_modules/@smithy/node-http-handler/dist-cjs/index.js:294:19
      at new Promise (:1:21)
      at /Users/Julian/Projects//node_modules/@smithy/node-http-handler/dist-cjs/index.js:245:12

Probably related: https://github.com/oven-sh/bun/pull/8368

dougludlow commented 7 months ago

I'm seeing the exact same error as above in v1.1.2.

rafaell-lycan commented 2 months ago

I just got the same error as well on v1.1.26 😬