Skip to content

Commit 5ef8f8f

Browse files
committed
Fix the fetchGraphQL test with the global fetch API unavailable for new Node.js versions.
1 parent e04bf55 commit 5ef8f8f

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Updated dev dependencies.
88
- Updated `jsconfig.json` `compilerOptions.module` to `nodenext`.
9+
- Fixed the `fetchGraphQL` test with the global `fetch` API unavailable for new versions of Node.js that have the `fetch` global.
910

1011
## 18.0.0
1112

fetchGraphQL.test.mjs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,26 @@ export default (tests) => {
2525
});
2626

2727
tests.add("`fetchGraphQL` with global `fetch` API unavailable.", async () => {
28-
deepStrictEqual(await fetchGraphQL("http://localhost"), {
29-
errors: [
30-
{
31-
message: "Fetch error.",
32-
extensions: {
33-
client: true,
34-
code: "FETCH_ERROR",
35-
fetchErrorMessage: "Global `fetch` API unavailable.",
36-
},
37-
},
38-
],
28+
const revertGlobals = revertableGlobals({
29+
fetch: undefined,
3930
});
31+
32+
try {
33+
deepStrictEqual(await fetchGraphQL("http://localhost"), {
34+
errors: [
35+
{
36+
message: "Fetch error.",
37+
extensions: {
38+
client: true,
39+
code: "FETCH_ERROR",
40+
fetchErrorMessage: "Global `fetch` API unavailable.",
41+
},
42+
},
43+
],
44+
});
45+
} finally {
46+
revertGlobals();
47+
}
4048
});
4149

4250
tests.add("`fetchGraphQL` with a fetch error.", async () => {

0 commit comments

Comments
 (0)