mock-github icon indicating copy to clipboard operation
mock-github copied to clipboard

Node 18 and @octokit/core v5.0.0 incompatability

Open ataylorme opened this issue 2 years ago • 6 comments

Describe the bug Moctokit does not work with Node 18. All .reply responses return the same result to Octokit. Setting the status as 200 and 404 do not differ the mock response`

I believe this is due to Node 18 using a new http client named undici for fetch API support

Looking at the code for Moctokit it uses nock, which has an open issue for undici support

To Reproduce Use Moctokit with Node 18 and @octokit/core v5.0.0

Expected behavior Proper mock responses are returned.

Additional context I don't actually expect this to be solved until Nock is updated but an incompatibility note in the README would be nice.

ataylorme avatar Aug 17 '23 17:08 ataylorme

Thank you for pointing this out. I will keep an eye out for this or see if there are any alternative because of https://github.com/nock/nock/issues/2397#issuecomment-1673676783

I will update the docs till then.

shubhbapna avatar Aug 17 '23 18:08 shubhbapna

I have updated the docs but will keep this issue open

shubhbapna avatar Aug 17 '23 18:08 shubhbapna

experimental support for fetch added to nock. I will soon start testing compatibility of this with mock-github

https://github.com/nock/nock/issues/2397#issuecomment-1925478357

shubhbapna avatar Mar 04 '24 15:03 shubhbapna

Not sure if I'm doing anything wrong, but I upgraded the latest main of this project, ran npm add nock@beta and got all tests to pass with minimal effort. I'll send a PR.

oliversalzburg avatar May 31 '24 09:05 oliversalzburg

Hey everyone, so sorry for the delay but thanks to @oliversalzburg a beta version of mock-github is available that supports mocking of the inbuilt fetch client in node 18 and up. It is currently beta since we depend on nock's beta release. Once nock releases a more stable version than I shall make a general release

shubhbapna avatar Jul 17 '24 18:07 shubhbapna

I upgraded all my actions to use the new beta and all tests are passing. I don't have many tests yet, because I was waiting for this project to work flawlessly, but what's there works :smile:

I noticed that I need to pass { request: { fetch } } explicitly to getOctoKit in my tests to make it work though. I don't understand yet why that is.

oliversalzburg avatar Jul 25 '24 10:07 oliversalzburg