Skip to content

Commit 2baa69b

Browse files
chore(deps): update dependency fetch-mock to v12 (#723)
* chore(deps): update dependency fetch-mock to v12 * updates tests to use the new v12 fetch-mock apis --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nick Floyd <[email protected]>
1 parent 1ffa99b commit 2baa69b

File tree

4 files changed

+305
-275
lines changed

4 files changed

+305
-275
lines changed

package-lock.json

+39-23
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
@@ -37,7 +37,7 @@
3737
"@types/node": "^22.0.0",
3838
"@vitest/coverage-v8": "^2.0.0",
3939
"esbuild": "^0.24.0",
40-
"fetch-mock": "^11.0.0",
40+
"fetch-mock": "^12.0.0",
4141
"glob": "^11.0.0",
4242
"prettier": "3.3.3",
4343
"semantic-release-plugin-update-version-in-files": "^1.0.0",

test/defaults.test.ts

+25-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fetchMock from "fetch-mock";
1+
import fetchMock, { FetchMock } from "fetch-mock";
22

33
import { describe, it, expect } from "vitest";
44
import { request } from "../src/index.ts";
@@ -9,19 +9,18 @@ describe("endpoint.defaults()", () => {
99
});
1010

1111
it("README example", () => {
12-
const mock = fetchMock
13-
.sandbox()
14-
.mock(
15-
"https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos?per_page=100",
16-
[],
17-
{
18-
headers: {
19-
accept: "application/vnd.github.v3+json",
20-
authorization: "token 0000000000000000000000000000000000000001",
21-
"user-agent": "myApp/1.2.3",
22-
},
12+
const mock = fetchMock.createInstance();
13+
mock.get(
14+
"https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos?per_page=100",
15+
[],
16+
{
17+
headers: {
18+
accept: "application/vnd.github.v3+json",
19+
authorization: "token 0000000000000000000000000000000000000001",
20+
"user-agent": "myApp/1.2.3",
2321
},
24-
);
22+
},
23+
);
2524

2625
const myRequest = request.defaults({
2726
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
@@ -32,7 +31,7 @@ describe("endpoint.defaults()", () => {
3231
org: "my-project",
3332
per_page: 100,
3433
request: {
35-
fetch: mock,
34+
fetch: mock.fetchHandler,
3635
},
3736
});
3837

@@ -42,19 +41,18 @@ describe("endpoint.defaults()", () => {
4241
});
4342

4443
it("repeated defaults", () => {
45-
const mock = fetchMock
46-
.sandbox()
47-
.get(
48-
"https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos",
49-
[],
50-
{
51-
headers: {
52-
accept: "application/vnd.github.v3.raw+json",
53-
authorization: "token 0000000000000000000000000000000000000001",
54-
"user-agent": "myApp/1.2.3",
55-
},
44+
const mock = fetchMock.createInstance();
45+
mock.get(
46+
"https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos",
47+
[],
48+
{
49+
headers: {
50+
accept: "application/vnd.github.v3.raw+json",
51+
authorization: "token 0000000000000000000000000000000000000001",
52+
"user-agent": "myApp/1.2.3",
5653
},
57-
);
54+
},
55+
);
5856

5957
const myProjectRequest = request.defaults({
6058
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
@@ -66,7 +64,7 @@ describe("endpoint.defaults()", () => {
6664
},
6765
org: "my-project",
6866
request: {
69-
fetch: mock,
67+
fetch: mock.fetchHandler,
7068
},
7169
});
7270
const myProjectRequestWithAuth = myProjectRequest.defaults({

0 commit comments

Comments
 (0)