Skip to content
Open
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
27 changes: 27 additions & 0 deletions implementors/node/README.md
Original file line number Diff line number Diff line change
@@ -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.
27 changes: 8 additions & 19 deletions implementors/node/run-tests.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
) {
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"));
Loading