Skip to content

Commit af75f95

Browse files
authored
Merge pull request #181 from bcomnes/node-test-runner
Convert to using the node test runner
2 parents fd8a38c + b2c22e1 commit af75f95

17 files changed

+538
-484
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
with:
4242
node-version: ${{ matrix.node }}
4343
- run: npm i
44-
- run: npm run test-mocha
44+
- run: npm run test
4545
- uses: codecov/codecov-action@v5
4646
if: ${{ github.event_name == 'pull_request' }}
4747
with:

.knip.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"$schema": "https://unpkg.com/knip@5/schema.json",
33
"entry": ["lib/index.js", "bin/*/*.js", "test-workspace/tasks/*.js"],
4-
"ignoreDependencies": ["yarn"]
4+
"ignoreDependencies": ["yarn", "spec"]
55
}

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module.exports = [
44
...require('neostandard')({
5-
env: ['mocha'],
5+
env: ['node', 'mocha'],
66
ignores: require('neostandard').resolveIgnoresFromGitignore(),
77
ts: true,
88
}),

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
"check:knip": "knip",
2323
"precheck": "node scripts/make-slink.js",
2424
"check": "node ./bin/run-p/index.js check:*",
25-
"pretest-mocha": "node scripts/make-slink.js",
26-
"test-mocha": "c8 mocha --timeout 120000",
27-
"test": "node ./bin/run-s/index.js check test-mocha",
28-
"watch": "mocha --timeout 120000 --watch --growl",
25+
"pretest": "node scripts/make-slink.js",
26+
"test": "node ./bin/run-s/index.js test:*",
27+
"test:check": "npm run check",
28+
"test:node-test": "c8 node --test --test-reporter spec --test-concurrency=1",
29+
"watch": "node --watch --test",
2930
"version": "auto-changelog -p --template keepachangelog auto-changelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md",
3031
"prepublishOnly": "git push --follow-tags && gh-release -y"
3132
},
@@ -47,7 +48,6 @@
4748
"installed-check": "^9.3.0",
4849
"jsdoc": "^4.0.0",
4950
"knip": "^5.23.3",
50-
"mocha": "^11.0.1",
5151
"neostandard": "^0.12.0",
5252
"yarn": "^1.12.3"
5353
},

test/aggregate-output.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
// Requirements
1010
// ------------------------------------------------------------------------------
1111

12-
const assert = require('assert').strict
12+
const { test, describe, before, after, beforeEach } = require('node:test')
13+
const assert = require('node:assert/strict')
1314
const nodeApi = require('../lib')
1415
const BufferStream = require('./lib/buffer-stream')
1516
const util = require('./lib/util')
@@ -48,15 +49,15 @@ describe('[aggregated-output] npm-run-all', () => {
4849
stdout = new BufferStream()
4950
})
5051

51-
it('Node API with parallel', async () => {
52+
test('Node API with parallel', async () => {
5253
await nodeApi(
5354
['test-task:delayed first 5000', 'test-task:delayed second 1000', 'test-task:delayed third 3000'],
5455
{ stdout, parallel: true, silent: true, aggregateOutput: true }
5556
)
5657
assert.equal(stdout.value, EXPECTED_PARALLELIZED_TEXT)
5758
})
5859

59-
it('Node API without parallel should fail', async () => {
60+
test('Node API without parallel should fail', async () => {
6061
try {
6162
await nodeApi(
6263
['test-task:delayed first 5000', 'test-task:delayed second 1000', 'test-task:delayed third 3000'],
@@ -68,15 +69,15 @@ describe('[aggregated-output] npm-run-all', () => {
6869
assert(false, 'should fail')
6970
})
7071

71-
it('npm-run-all command with parallel', async () => {
72+
test('npm-run-all command with parallel', async () => {
7273
await runAll(
7374
['--parallel', 'test-task:delayed first 5000', 'test-task:delayed second 1000', 'test-task:delayed third 3000', '--silent', '--aggregate-output'],
7475
stdout
7576
)
7677
assert.equal(stdout.value, EXPECTED_PARALLELIZED_TEXT)
7778
})
7879

79-
it('npm-run-all command without parallel should fail', async () => {
80+
test('npm-run-all command without parallel should fail', async () => {
8081
try {
8182
await runAll(
8283
['test-task:delayed first 5000', 'test-task:delayed second 1000', 'test-task:delayed third 3000', '--silent', '--aggregate-output'],
@@ -88,7 +89,7 @@ describe('[aggregated-output] npm-run-all', () => {
8889
assert(false, 'should fail')
8990
})
9091

91-
it('run-s command should fail', async () => {
92+
test('run-s command should fail', async () => {
9293
try {
9394
await runSeq(
9495
['test-task:delayed first 5000', 'test-task:delayed second 1000', 'test-task:delayed third 3000', '--silent', '--aggregate-output'],
@@ -100,7 +101,7 @@ describe('[aggregated-output] npm-run-all', () => {
100101
assert(false, 'should fail')
101102
})
102103

103-
it('run-p command', async () => {
104+
test('run-p command', async () => {
104105
await runPar(
105106
[
106107
'test-task:delayed first 5000',

0 commit comments

Comments
 (0)