mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 21:46:48 +00:00

This commit introduces a node:test reporter to the common utils. This reporter can be used to silence output other than errors from node:test. This is useful because in Node's own test suite, the output of node:test is included in the output of the Python test runner. Refs: https://github.com/nodejs/node/issues/49120 PR-URL: https://github.com/nodejs/node/pull/56438 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
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');
|
|
|
|
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);
|
|
const failureCount = (cp.stdout.toString().match(/Test failure:/g) || []).length;
|
|
assert.strictEqual(failureCount, 2);
|
|
});
|
|
|
|
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: { ...process.env, FAIL_FAST: 'true' } });
|
|
const failureCount = (cp.stdout.toString().match(/Test failure:/g) || []).length;
|
|
assert.strictEqual(failureCount, 1);
|
|
});
|