You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suddenly all tests depending on nock starts to fail
mkdir foo
cd foo
npm init -y -f
npm i -S @octokit/rest nock
demo.js
const{ Octokit }=require('@octokit/rest')constnock=require('nock')constfetch=require('node-fetch')nock.recorder.rec()nock("https://api.github.com").post("/graphql").reply(200,{data: {hello: "world"}});constoctokit=newOctokit({request:{fetch}})octokit.graphql(`{ whatever }`).then(res=>console.log(res)).catch(err=>console.log(err.message))// This endpoint requires you to be authenticated
Instead of expected, mocked response I'm receiving and error "This endpoint requires you to be authenticated"
(node:41108) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
When enabling trace warning as node suggests I see this piece of code in @octokit/request.js:
constfetch=requestOptions.request&&requestOptions.request.fetch||globalThis.fetch||/* istanbul ignore next */nodeFetch;
and indeed if I will put nodeFetch in first place, suddenly everything starts to work
current workaround is already suggested somewhere in stackoverflow
so we may want to do something like this (note that request.js library depends on node-fetch):
gr2m
added
Type: Support
Any questions, information, or general needs around the SDK or GitHub APIs
and removed
Type: Bug
Something isn't working as documented
labels
Feb 24, 2023
What happened?
Suddenly all tests depending on nock starts to fail
mkdir foo cd foo npm init -y -f npm i -S @octokit/rest nock
demo.js
Instead of expected, mocked response I'm receiving and error "This endpoint requires you to be authenticated"
Which makes me believe tests like this 1323-parameter-deprecation-bug-test.js will also fail
Meanwhile, node complains:
When enabling trace warning as node suggests I see this piece of code in @octokit/request.js:
and indeed if I will put nodeFetch in first place, suddenly everything starts to work
current workaround is already suggested somewhere in stackoverflow
so we may want to do something like this (note that request.js library depends on node-fetch):
Versions
"@octokit/rest": "^19.0.7"
"nock": "^13.3.0"
node: v18.5.0
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: