Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use native type stripping of Node.js in node testing #6339

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ jobs:
with:
node-version: ${{ matrix.node }}

- run: npm install
working-directory: _tools/node_test_runner

- name: Run tests
run: deno task test:node

Expand Down
30 changes: 0 additions & 30 deletions _tools/node_test_runner/deno_compat_hooks.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2018-2025 the Deno authors. MIT license.

import { transform } from "sucrase";
import { readFile } from "node:fs/promises";
import * as path from "node:path";
import { pathToFileURL } from "node:url";
Expand All @@ -21,32 +20,3 @@ export async function resolve(specifier, context, nextResolve) {

return await nextResolve(specifier, context);
}

export async function load(specifier, context, nextLoad) {
const { format, source } = await nextLoad(specifier, context).catch(
async (error) => {
if (
error.code === "ERR_UNKNOWN_FILE_EXTENSION" &&
specifier.endsWith(".ts")
) {
return await nextLoad(specifier, {
...context,
format: "module",
});
} else {
throw error;
}
},
);

if (source && specifier.endsWith(".ts")) {
return {
format,
source: encoder.encode(
transform(decoder.decode(source), { transforms: ["typescript"] }).code,
),
};
}

return { format, source };
}
6 changes: 4 additions & 2 deletions _tools/node_test_runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "node_test_runner",
"private": true,
"dependencies": {
"@deno/shim-deno-test": "^0.5.0",
"sucrase": "^3.35.0"
"@deno/shim-deno-test": "^0.5.0"
},
"engines": {
"node": ">=23.6.0"
}
}
2 changes: 1 addition & 1 deletion collections/max_with.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function maxWith<T>(
let isFirst = true;

for (const current of array) {
if (isFirst || comparator(current, <T> max) > 0) {
if (isFirst || comparator(current, max as T) > 0) {
max = current;
isFirst = false;
}
Expand Down
2 changes: 1 addition & 1 deletion collections/min_with.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function minWith<T>(
let isFirst = true;

for (const current of array) {
if (isFirst || comparator(current, <T> min) < 0) {
if (isFirst || comparator(current, min as T) < 0) {
min = current;
isFirst = false;
}
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"tasks": {
"test": "deno test --unstable-http --unstable-webgpu --doc --allow-all --parallel --coverage --trace-leaks --clean",
"test:browser": "git grep --name-only \"This module is browser compatible.\" | grep -v deno.json | grep -v .github/workflows | grep -v _tools | grep -v encoding/README.md | grep -v media_types/vendor/update.ts | xargs deno check --config browser-compat.tsconfig.json",
"test:node": "node --import ./_tools/node_test_runner/register_deno_shim.mjs ./_tools/node_test_runner/run_test.mjs",
"test:node": "(cd _tools/node_test_runner && npm install) && node --import ./_tools/node_test_runner/register_deno_shim.mjs ./_tools/node_test_runner/run_test.mjs",
"fmt:licence-headers": "deno run --allow-read --allow-write ./_tools/check_licence.ts",
"lint:deprecations": "deno run --allow-read --allow-net --allow-env ./_tools/check_deprecation.ts",
"lint:circular": "deno run --allow-env --allow-read --allow-write --allow-net=deno.land,jsr.io ./_tools/check_circular_package_dependencies.ts",
Expand Down
Loading