diff --git a/implementors/node/README.md b/implementors/node/README.md new file mode 100644 index 0000000..d6aca27 --- /dev/null +++ b/implementors/node/README.md @@ -0,0 +1,27 @@ +# Harness of Node.js + +## Build addons + +To build the addons, run the following command: + +```bash +$ npm run addons:configure +$ npm run addons:build +``` + +## Running tests + +Run the following command to run the tests: + +```bash +$ npm run node:test +``` + +To run a specific test file, use the `--test-name-pattern` flag: + +```bash +$ NODE_OPTIONS=--test-name-pattern=js-native-api/test_constructor/test_null npm run node:test +``` + +The test names are their relative path to the `tests` folder, with file extensions. +The pattern can be a regular expression. diff --git a/implementors/node/run-tests.ts b/implementors/node/run-tests.ts index 1d341b7..3656981 100644 --- a/implementors/node/run-tests.ts +++ b/implementors/node/run-tests.ts @@ -1,36 +1,25 @@ import path from "node:path"; -import { test, type TestContext } from "node:test"; +import { test } from "node:test"; import { listDirectoryEntries, runFileInSubprocess } from "./tests.ts"; const ROOT_PATH = path.resolve(import.meta.dirname, "..", ".."); const TESTS_ROOT_PATH = path.join(ROOT_PATH, "tests"); -async function populateSuite( - testContext: TestContext, +function populateSuite( dir: string -): Promise { +) { const { directories, files } = listDirectoryEntries(dir); for (const file of files) { - await testContext.test(file, () => runFileInSubprocess(dir, file)); + test(path.relative(TESTS_ROOT_PATH, path.join(dir, file)), () => runFileInSubprocess(dir, file)); } for (const directory of directories) { - await testContext.test(directory, async (subTest) => { - await populateSuite(subTest, path.join(dir, directory)); - }); + populateSuite(path.join(dir, directory)); } } -test("harness", async (t) => { - await populateSuite(t, path.join(TESTS_ROOT_PATH, "harness")); -}); - -test("js-native-api", async (t) => { - await populateSuite(t, path.join(TESTS_ROOT_PATH, "js-native-api")); -}); - -test("node-api", async (t) => { - await populateSuite(t, path.join(TESTS_ROOT_PATH, "node-api")); -}); +populateSuite(path.join(TESTS_ROOT_PATH, "harness")); +populateSuite(path.join(TESTS_ROOT_PATH, "js-native-api")); +populateSuite(path.join(TESTS_ROOT_PATH, "node-api"));