-
Notifications
You must be signed in to change notification settings - Fork 331
Closed
Labels
Type: SupportAny questions, information, or general needs around the SDK or GitHub APIsAny questions, information, or general needs around the SDK or GitHub APIs
Description
What happened?
Suddenly all tests depending on nock starts to fail
mkdir foo
cd foo
npm init -y -f
npm i -S @octokit/rest nockdemo.js
const { Octokit } = require('@octokit/rest')
const nock = require('nock')
const fetch = require('node-fetch')
nock.recorder.rec()
nock("https://api.github.com")
.post("/graphql")
.reply(200, {data: {hello: "world"}});
const octokit = new Octokit({request:{fetch}})
octokit.graphql(`{ whatever }`)
.then(res => console.log(res))
.catch(err => console.log(err.message)) // This endpoint requires you to be authenticatedInstead 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:
(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:
const fetch = 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):
const fetch = require('node-fetch')
const octokit = new Octokit({request:{fetch}})Versions
"@octokit/rest": "^19.0.7"
"nock": "^13.3.0"
node: v18.5.0
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
eduardoconceicao, j0k3r, BaCaRoZzo, codepunkt, jtsaito and 2 morecodepunkt
Metadata
Metadata
Assignees
Labels
Type: SupportAny questions, information, or general needs around the SDK or GitHub APIsAny questions, information, or general needs around the SDK or GitHub APIs
Type
Projects
Status
✅ Done