From 542ffc6750d29d5a626263cbbee19250849222ce Mon Sep 17 00:00:00 2001 From: Jayden Seric Date: Sun, 22 Oct 2023 20:45:32 +1100 Subject: [PATCH] Use the `node:` URL scheme for Node.js builtin module imports. --- changelog.md | 1 + createUploadLink.test.mjs | 3 ++- formDataAppendFile.test.mjs | 2 +- test/assertBundleSize.mjs | 5 +++-- test/createUnexpectedCallError.mjs | 2 +- test/polyfillFile.mjs | 2 +- test/timeLimitPromise.mjs | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index b2a0450..a820d59 100644 --- a/changelog.md +++ b/changelog.md @@ -60,6 +60,7 @@ - Run tests with Node.js v18, v20, v21. - Updated `actions/checkout` to v3. - Updated `actions/setup-node` to v3. +- Use the `node:` URL scheme for Node.js builtin module imports. - Reorganized the test file structure. - In tests, for objects with the property `headers` that as of [`@apollo/client`](https://npm.im/@apollo/client) [v3.7.0](https://github.com/apollographql/apollo-client/releases/tag/v3.7.0) is a null-prototype object, use the assertion `deepEqual` instead of `deepStrictEqual`. diff --git a/createUploadLink.test.mjs b/createUploadLink.test.mjs index 74d5259..3f92dad 100644 --- a/createUploadLink.test.mjs +++ b/createUploadLink.test.mjs @@ -1,9 +1,10 @@ import "./test/polyfillFile.mjs"; +import { deepEqual, deepStrictEqual, strictEqual } from "node:assert"; + import { ApolloLink } from "@apollo/client/link/core/ApolloLink.js"; import { concat } from "@apollo/client/link/core/concat.js"; import { execute } from "@apollo/client/link/core/execute.js"; -import { deepEqual, deepStrictEqual, strictEqual } from "assert"; import gql from "graphql-tag"; import revertableGlobals from "revertable-globals"; diff --git a/formDataAppendFile.test.mjs b/formDataAppendFile.test.mjs index 8595924..bc878c3 100644 --- a/formDataAppendFile.test.mjs +++ b/formDataAppendFile.test.mjs @@ -1,6 +1,6 @@ import "./test/polyfillFile.mjs"; -import { strictEqual } from "assert"; +import { strictEqual } from "node:assert"; import formDataAppendFile from "./formDataAppendFile.mjs"; import assertBundleSize from "./test/assertBundleSize.mjs"; diff --git a/test/assertBundleSize.mjs b/test/assertBundleSize.mjs index 6d32540..cf35ce2 100644 --- a/test/assertBundleSize.mjs +++ b/test/assertBundleSize.mjs @@ -1,7 +1,8 @@ -import { fail } from "assert"; +import { fail } from "node:assert"; +import { fileURLToPath } from "node:url"; + import esbuild from "esbuild"; import { gzipSize } from "gzip-size"; -import { fileURLToPath } from "url"; /** * Asserts the minified and gzipped bundle size of a module. diff --git a/test/createUnexpectedCallError.mjs b/test/createUnexpectedCallError.mjs index 34e0aef..7fdbb1f 100644 --- a/test/createUnexpectedCallError.mjs +++ b/test/createUnexpectedCallError.mjs @@ -1,4 +1,4 @@ -import { AssertionError } from "assert"; +import { AssertionError } from "node:assert"; /** * Creates an assertion error that a function was unexpectedly called. diff --git a/test/polyfillFile.mjs b/test/polyfillFile.mjs index 09ea552..d300b84 100644 --- a/test/polyfillFile.mjs +++ b/test/polyfillFile.mjs @@ -1,4 +1,4 @@ -import { File as NodeFile } from "buffer"; +import { File as NodeFile } from "node:buffer"; // TODO: Delete this polyfill once all supported Node.js versions have the // global `File`: diff --git a/test/timeLimitPromise.mjs b/test/timeLimitPromise.mjs index 749a423..4155172 100644 --- a/test/timeLimitPromise.mjs +++ b/test/timeLimitPromise.mjs @@ -1,4 +1,4 @@ -import { AssertionError } from "assert"; +import { AssertionError } from "node:assert"; /** * Time limits a promise. It will reject with an assertion error if it doesn’t