-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! test: add error only reporter for node:test
- Loading branch information
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const assert = require('node:assert'); | ||
const { test } = require('node:test'); | ||
|
||
test('fail', () => { | ||
assert.fail('a.mjs fail'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const assert = require('node:assert'); | ||
const { test } = require('node:test'); | ||
|
||
test('fail', () => { | ||
assert.fail('b.mjs fail'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
Check failure on line 1 in test/parallel/test-runner-error-reporter.js GitHub Actions / lint-js-and-md
|
||
|
||
const fixtures = require('../common/fixtures'); | ||
const assert = require('node:assert'); | ||
const { spawnSync } = require('node:child_process'); | ||
const { test } = require('node:test'); | ||
const cwd = fixtures.path('test-runner', 'error-reporter-fail-fast'); | ||
const env = { ...process.env }; | ||
|
||
test('all tests failures reported without FAIL_FAST flag', async () => { | ||
const args = [ | ||
'--test-reporter=./test/common/test-error-reporter.js', | ||
'--test-concurrency=1', | ||
'--test', | ||
`${cwd}/*.mjs`, | ||
]; | ||
const cp = spawnSync(process.execPath, args, { env }); | ||
const failureCount = (cp.stdout.toString().match(/Test failure:/g) || []).length; | ||
assert.strictEqual(failureCount, 2, 'Expected two test failures without FAIL_FAST'); | ||
}); | ||
|
||
test('FAIL_FAST stops test execution after first failure', async () => { | ||
const args = [ | ||
'--test-reporter=./test/common/test-error-reporter.js', | ||
'--test-concurrency=1', | ||
'--test', | ||
`${cwd}/*.mjs`, | ||
]; | ||
const cp = spawnSync(process.execPath, args, { env: { ...env, FAIL_FAST: 'true' } }); | ||
const failureCount = (cp.stdout.toString().match(/Test failure:/g) || []).length; | ||
assert.strictEqual(failureCount, 1, 'Expected one test failure with FAIL_FAST'); | ||
}); |