diff --git a/package-lock.json b/package-lock.json index a68666a8e..c8cabbf8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "devDependencies": { "@eslint/js": "^9.10.0", "@types/brace-expansion": "^1.1.2", - "@types/node": "^22.5.4", + "@types/node": "^18.19.130", "@types/node-forge": "^1.3.0", "@types/proper-lockfile": "^4.1.2", "@types/selfsigned": "^2.0.1", @@ -1505,13 +1505,12 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.19.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.3.tgz", - "integrity": "sha512-1N9SBnWYOJTrNZCdh/yJE+t910Y128BoyY+zBLWhL3r0TYzlTmFdXrPwHL9DyFZmlEXNQQolTZh3KHV31QDhyA==", + "version": "18.19.130", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz", + "integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==", "dev": true, - "license": "MIT", "dependencies": { - "undici-types": "~6.21.0" + "undici-types": "~5.26.4" } }, "node_modules/@types/node-forge": { @@ -1614,7 +1613,6 @@ "integrity": "sha512-N9lBGA9o9aqb1hVMc9hzySbhKibHmB+N3IpoShyV6HyQYRGIhlrO5rQgttypi+yEeKsKI4idxC8Jw6gXKD4THA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.49.0", "@typescript-eslint/types": "8.49.0", @@ -2052,7 +2050,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -3085,7 +3082,6 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -6329,7 +6325,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -6467,7 +6462,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -6525,11 +6519,10 @@ } }, "node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", - "dev": true, - "license": "MIT" + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true }, "node_modules/unicorn-magic": { "version": "0.3.0", diff --git a/package.json b/package.json index 8ea0940f6..4155e6f21 100644 --- a/package.json +++ b/package.json @@ -392,7 +392,7 @@ "output": [] }, "test:watch": { - "command": "uvu lib/test \"^watch\\.test\\.js$\"", + "command": "node --test --test-reporter=dot lib/test/watch.test.js", "env": { "NODE_OPTIONS": "--enable-source-maps" }, @@ -417,7 +417,7 @@ "devDependencies": { "@eslint/js": "^9.10.0", "@types/brace-expansion": "^1.1.2", - "@types/node": "^22.5.4", + "@types/node": "^18.19.130", "@types/node-forge": "^1.3.0", "@types/proper-lockfile": "^4.1.2", "@types/selfsigned": "^2.0.1", diff --git a/src/test/util/rig-test.ts b/src/test/util/rig-test.ts index ed1cc3e47..20a8df352 100644 --- a/src/test/util/rig-test.ts +++ b/src/test/util/rig-test.ts @@ -100,9 +100,23 @@ export const rigTest = ( }; export function rigTestNode( - fn: (args: {rig: WireitTestRig}) => unknown, + handler: (args: {rig: WireitTestRig}) => unknown, + options?: {flaky?: boolean}, ): TestFn { - return async function () { - await fn({rig: await WireitTestRig.setup()}); + const runTest = async () => { + await using rig = await WireitTestRig.setup(); + await handler({rig}); }; + if (options?.flaky) { + return async () => { + try { + return await runTest(); + } catch { + console.log('Test failed, retrying...'); + } + return await runTest(); + }; + } else { + return runTest; + } } diff --git a/src/test/watch.test.ts b/src/test/watch.test.ts index c29cf37b9..1d1b17457 100644 --- a/src/test/watch.test.ts +++ b/src/test/watch.test.ts @@ -4,29 +4,27 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {suite} from 'uvu'; -import * as assert from 'uvu/assert'; -import {rigTest} from './util/rig-test.js'; +import {test, describe} from 'node:test'; +import * as assert from 'node:assert'; +import {rigTestNode as rigTest} from './util/rig-test.js'; import type {WireitTestRig} from './util/test-rig.js'; -tests('WIREIT_WATCH_STRATEGY='); +void describe('WIREIT_WATCH_STRATEGY=', () => tests()); -tests('WIREIT_WATCH_STRATEGY=poll', (rig: WireitTestRig) => { - rig.env.WIREIT_WATCH_STRATEGY = 'poll'; - // Default is 500, let's speed up the tests. - rig.env.WIREIT_WATCH_POLL_MS = '50'; -}); +void describe('WIREIT_WATCH_STRATEGY=poll', () => + tests((rig: WireitTestRig) => { + rig.env.WIREIT_WATCH_STRATEGY = 'poll'; + // Default is 500, let's speed up the tests. + rig.env.WIREIT_WATCH_POLL_MS = '50'; + })); function tests( - suiteName: string, // TODO(aomarks) There should be a better way to prepare a rig without having // to remember to call it in every test case. We should refactor to use the // node test runner, maybe can do this as part of that. prepareRig: (rig: WireitTestRig) => void | Promise = () => {}, ) { - const test = suite(suiteName); - - test( + void test( 'runs initially and waits for SIGINT', rigTest( async ({rig}) => { @@ -80,7 +78,7 @@ function tests( ), ); - test( + void test( 'runs again when input file changes after execution', rigTest( async ({rig}) => { @@ -131,7 +129,7 @@ function tests( ), ); - test( + void test( 'runs again when new input file created', rigTest( async ({rig}) => { @@ -182,7 +180,7 @@ function tests( ), ); - test( + void test( 'runs again when input file deleted', rigTest( async ({rig}) => { @@ -231,7 +229,7 @@ function tests( ), ); - test( + void test( 'runs again when input file changes in the middle of execution', rigTest(async ({rig}) => { await prepareRig(rig); @@ -279,7 +277,7 @@ function tests( }), ); - test( + void test( 'reloads config when package.json changes and runs again', rigTest( async ({rig}) => { @@ -340,7 +338,7 @@ function tests( ), ); - test( + void test( 'changes are detected in same-package dependencies', rigTest( async ({rig}) => { @@ -424,7 +422,7 @@ function tests( ), ); - test( + void test( 'changes are detected in cross-package dependencies', rigTest( async ({rig}) => { @@ -514,7 +512,7 @@ function tests( ), ); - test( + void test( 'error from script is not fatal', rigTest( async ({rig}) => { @@ -567,7 +565,7 @@ function tests( ), ); - test( + void test( 'recovers from analysis errors', rigTest( async ({rig}) => { @@ -675,7 +673,7 @@ function tests( ), ); - test( + void test( 'watchers understand negations', rigTest( async ({rig}) => { @@ -739,7 +737,7 @@ function tests( ), ); - test( + void test( '.dotfiles are watched', rigTest( async ({rig}) => { @@ -787,7 +785,7 @@ function tests( ), ); - test( + void test( 'package-lock.json files are watched', rigTest( async ({rig}) => { @@ -833,7 +831,7 @@ function tests( ), ); - test( + void test( 'debounces when two scripts are watching the same file', rigTest( async ({rig}) => { @@ -900,7 +898,7 @@ function tests( ), ); - test( + void test( 'strips leading slash from watch paths', rigTest( async ({rig}) => { @@ -947,7 +945,7 @@ function tests( ), ); - test( + void test( 'script fails but still emits output consumed by another script', rigTest( async ({rig}) => { @@ -1028,7 +1026,7 @@ function tests( ), ); - test( + void test( 'input file changes but the contents are the same', rigTest( async ({rig}) => { @@ -1068,6 +1066,4 @@ function tests( {flaky: true}, ), ); - - test.run(); }