kiegroup / mock-github

A library to create a local github environment and easily mock github APIs using an octokit like interface
Apache License 2.0
60 stars 5 forks source link

Node 18 and @octokit/core v5.0.0 incompatability #77

Open ataylorme opened 1 year ago

ataylorme commented 1 year ago

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.

shubhbapna commented 1 year ago

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 commented 1 year ago

I have updated the docs but will keep this issue open

shubhbapna commented 8 months ago

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

oliversalzburg commented 5 months ago

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.

shubhbapna commented 3 months ago

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

oliversalzburg commented 3 months ago

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.