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

Finish move to nodejs org #9

Merged
merged 18 commits into from
Jun 2, 2022
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# node-core-test
# The `test` npm package

[![CI](https://github.com/juliangruber/node-core-test/actions/workflows/ci.yml/badge.svg)](https://github.com/juliangruber/node-core-test/actions/workflows/ci.yml)
[![CI](https://github.com/nodejs/node-core-test/actions/workflows/ci.yml/badge.svg)](https://github.com/nodejs/node-core-test/actions/workflows/ci.yml)

This is a user-land port of [`node:test`](https://github.com/nodejs/node/blob/adaf60240559ffb58636130950262ee3237b7a41/doc/api/test.md),
This is a user-land port of [`node:test`](https://nodejs.org/api/test.html),
the experimental test runner introduced in Node.js 18. This module makes it
available in Node.js 14 and later.

Expand Down Expand Up @@ -31,11 +31,11 @@ The `node:test` module facilitates the creation of JavaScript tests that
report results in [TAP][] format. To access it:

```mjs
import test from 'node-core-test'
import test from 'test'
```

```cjs
const test = require('node-core-test')
const test = require('test')
```

Tests created via the `test` module consist of a single function that is
Expand Down Expand Up @@ -160,14 +160,14 @@ test('skip() method with message', t => {

### `only` tests

If `node-core-test` is started with the `--test-only` command-line option, it is
If `node--test` is started with the `--test-only` command-line option, it is
possible to skip all top level tests except for a selected subset by passing
the `only` option to the tests that should be run. When a test with the `only`
option set is run, all subtests are also run. The test context's `runOnly()`
method can be used to implement the same behavior at the subtest level.

```js
// Assume node-core-test is run with the --test-only command-line option.
// Assume node--test is run with the --test-only command-line option.
// The 'only' option is set, so this test is run.
test('this test is run', { only: true }, async t => {
// Within this test, all subtests are run by default.
Expand Down Expand Up @@ -234,8 +234,6 @@ test('a test that creates asynchronous activity', t => {
The Node.js test runner can be invoked from the command line:

```bash
node-core-test --test
# or use the shortcut version:
node--test
```

Expand All @@ -249,7 +247,7 @@ Alternatively, one or more paths can be provided as the final argument(s) to
the Node.js command, as shown below.

```bash
node-core-test --test test1.js test2.mjs custom_test_dir/
test --test test1.js test2.mjs custom_test_dir/
juliangruber marked this conversation as resolved.
Show resolved Hide resolved
node--test test1.js test2.mjs custom_test_dir/
```

Expand Down
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "node-core-test",
"name": "test",
"version": "2.0.0",
"description": "Node 18's node:test, as a node module",
"description": "Node.js 18's node:test, as an npm package",
"license": "MIT",
"repository": "juliangruber/node-core-test",
"repository": "nodejs/node-core-test",
"main": "./index.js",
"types": "./index.d.ts",
"bin": {
"node--test": "./bin/node--test.js",
"node-core-test": "./bin/node-core-test.js"
"test": "./bin/node-core-test.js"
},
"imports": {
"#internal/*": "./lib/internal/*.js",
Expand Down
2 changes: 1 addition & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const noop = () => {}

const { bin } = require('../../package.json')

process.execPath = path.resolve(__dirname, '..', '..', bin['node-core-test'])
process.execPath = path.resolve(__dirname, '..', '..', bin.test)
Comment on lines 7 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could get rid of the magic string here (feel free to ignore, that's going to be useful only in the unlikely event of this pacakge switching name ever again).

Suggested change
const { bin } = require('../../package.json')
process.execPath = path.resolve(__dirname, '..', '..', bin['node-core-test'])
process.execPath = path.resolve(__dirname, '..', '..', bin.test)
const { bin, name } = require('../../package.json')
process.execPath = path.resolve(__dirname, '..', '..', bin[name])


const mustCallChecks = []

Expand Down
2 changes: 1 addition & 1 deletion test/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { exec } = require('node:child_process')
const { createInterface } = require('node:readline')

const { bin } = require('../package.json')
const binPath = resolve(__dirname, '..', bin['node-core-test'])
const binPath = resolve(__dirname, '..', bin.test)

const MESSAGE_FOLDER = join(__dirname, './message/')
const WAIT_FOR_ELLIPSIS = Symbol('wait for ellispis')
Expand Down
2 changes: 1 addition & 1 deletion test/node-core-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const test = require('#node:test')

const { bin } = require('../package.json')

const binPath = resolve(__dirname, '..', bin['node-core-test'])
const binPath = resolve(__dirname, '..', bin.test)
const nodeDashDashTestPath = resolve(__dirname, '..', bin['node--test'])
const fixturesDir = join(__dirname, 'fixtures', 'node-core-test')

Expand Down