Skip to content

Commit 751b522

Browse files
chore(deps): update dependency fetch-mock to v12 (#470)
1 parent 5ad12fd commit 751b522

File tree

4 files changed

+52
-62
lines changed

4 files changed

+52
-62
lines changed

package-lock.json

+39-50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@types/node": "^22.0.0",
4949
"@vitest/coverage-v8": "^2.0.3",
5050
"esbuild": "^0.24.0",
51-
"fetch-mock": "^11.0.0",
51+
"fetch-mock": "^12.0.0",
5252
"glob": "^11.0.0",
5353
"nock": "^14.0.0-beta.8",
5454
"prettier": "^3.2.4",

test/integration/smoke.test.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,32 @@ describe("Smoke tests", () => {
1616

1717
it("userAgent option", () => {
1818
const mock = fetchMock
19-
.sandbox()
20-
.getOnce("https://api.github.com/", (_url, { headers }) => {
21-
// @ts-ignore headers has wrong typing in fetch-mock 8.3.2
22-
expect(headers["user-agent"]).toMatch(/^my-app\/1.2.3 /);
19+
.createInstance()
20+
.getOnce("https://api.github.com/", (_url) => {
21+
expect(
22+
mock.callHistory.calls()[0].options.headers!["user-agent"],
23+
).toMatch(/^my-app\/1.2.3 /);
2324

2425
return { ok: true };
2526
});
2627

2728
const octokit = new Octokit({
2829
userAgent: "my-app/1.2.3",
2930
request: {
30-
fetch: mock,
31+
fetch: mock.fetchHandler,
3132
},
3233
});
3334
return octokit.request("/");
3435
});
3536

3637
it("@octokit/plugin-rest-endpoint-methods", () => {
3738
const mock = fetchMock
38-
.sandbox()
39+
.createInstance()
3940
.getOnce("path:/repos/octocat/hello-world", { ok: true });
4041

4142
const octokit = new Octokit({
4243
request: {
43-
fetch: mock,
44+
fetch: mock.fetchHandler,
4445
},
4546
});
4647

@@ -58,7 +59,7 @@ describe("Smoke tests", () => {
5859

5960
it("@octokit/plugin-request-log", () => {
6061
const mock = fetchMock
61-
.sandbox()
62+
.createInstance()
6263
.getOnce("path:/", { status: 200, body: {} })
6364
.getOnce("path:/", { status: 404, body: {} }, { overwriteRoutes: false });
6465

@@ -72,7 +73,7 @@ describe("Smoke tests", () => {
7273
const octokit = new Octokit({
7374
log: consoleStub,
7475
request: {
75-
fetch: mock,
76+
fetch: mock.fetchHandler,
7677
},
7778
});
7879

test/issues/881-redirect-url.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("https://github.com/octokit/rest.js/issues/881", () => {
99
"https://issue-881-codeload.github.com/octocat/Hello-World/legacy.tar.gz/master";
1010

1111
const mock = fetchMock
12-
.sandbox()
12+
.createInstance()
1313
.headOnce(
1414
"https://api.github.com/repos/octocat/Hello-World/tarball/master",
1515
{
@@ -20,7 +20,7 @@ describe("https://github.com/octokit/rest.js/issues/881", () => {
2020

2121
const octokit = new Octokit({
2222
request: {
23-
fetch: mock,
23+
fetch: mock.fetchHandler,
2424
},
2525
});
2626

0 commit comments

Comments
 (0)