Skip to content

Commit d019524

Browse files
chore(deps): update dependency fetch-mock to v12 (#262)
* chore(deps): update dependency fetch-mock to v12 * adapt for fetch-mock v12 * account for new CallLog --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: wolfy1339 <[email protected]>
1 parent 6e0a7a5 commit d019524

File tree

4 files changed

+39
-26
lines changed

4 files changed

+39
-26
lines changed

package-lock.json

Lines changed: 23 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@types/node": "^22.0.0",
3636
"@vitest/coverage-v8": "^3.0.0",
3737
"esbuild": "^0.24.0",
38-
"fetch-mock": "^11.0.0",
38+
"fetch-mock": "^12.0.0",
3939
"glob": "^10.2.6",
4040
"prettier": "3.4.2",
4141
"semantic-release-plugin-update-version-in-files": "^1.0.0",

test/paginate.test.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,12 @@ describe("pagination", () => {
372372
],
373373
};
374374
const mock = fetchMock
375-
.sandbox()
375+
.createInstance()
376376
.post("https://api.github.com/graphql", mockResponse);
377377

378-
const octokit = new PatchedOctokit({ request: { fetch: mock } });
378+
const octokit = new PatchedOctokit({
379+
request: { fetch: mock.fetchHandler },
380+
});
379381
const query = `{
380382
viewer {
381383
bioHtml
@@ -398,11 +400,15 @@ describe("pagination", () => {
398400
});
399401

400402
it(".paginate() passes 500 errors on.", async (): Promise<void> => {
401-
const mock = fetchMock.sandbox().post("https://api.github.com/graphql", {
402-
status: 500,
403-
});
403+
const mock = fetchMock
404+
.createInstance()
405+
.post("https://api.github.com/graphql", {
406+
status: 500,
407+
});
404408

405-
const octokit = new PatchedOctokit({ request: { fetch: mock } });
409+
const octokit = new PatchedOctokit({
410+
request: { fetch: mock.fetchHandler },
411+
});
406412
const func = async () =>
407413
await octokit.graphql.paginate<TestResponseType>(`
408414
query paginate($cursor: String) {

test/testHelpers/mock-octokit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const MockOctokit = ({ responses = [{}] }: { responses?: any[] } = {}) => {
88
let calledQueries: string[] = [];
99
let passedVariables: any[] = [];
1010
let callCount = 0;
11-
const mock = fetchMock.sandbox().post(
11+
const mock = fetchMock.createInstance().post(
1212
"https://api.github.com/graphql",
13-
(_, options) => {
13+
({ options }) => {
1414
calledQueries.push(JSON.parse(options.body!.toString()).query);
1515
passedVariables.push(JSON.parse(options.body!.toString()).variables);
1616
callCount = callCount + 1;
@@ -21,7 +21,7 @@ const MockOctokit = ({ responses = [{}] }: { responses?: any[] } = {}) => {
2121

2222
const octokit = new PatchedOctokit({
2323
request: {
24-
fetch: mock,
24+
fetch: mock.fetchHandler,
2525
},
2626
});
2727

0 commit comments

Comments
 (0)