mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
Signed-off-by: semimikoh <ejffjeosms@gmail.com> PR-URL: https://github.com/nodejs/node/pull/64208 Fixes: https://github.com/nodejs/node/issues/64203 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
116 lines
3.3 KiB
JavaScript
116 lines
3.3 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 fixture1 = fixtures.path('test-runner', 'no-isolation', 'one.test.js');
|
|
const fixture2 = fixtures.path('test-runner', 'no-isolation', 'two.test.js');
|
|
const asyncBuildFilteredSuite =
|
|
fixtures.path('test-runner', 'filtered-suite-async-build.mjs');
|
|
|
|
test('works with --test-only', () => {
|
|
const args = [
|
|
'--test',
|
|
'--test-reporter=tap',
|
|
'--test-isolation=none',
|
|
'--test-only',
|
|
fixture1,
|
|
fixture2,
|
|
];
|
|
const child = spawnSync(process.execPath, args);
|
|
const stdout = child.stdout.toString();
|
|
|
|
assert.strictEqual(child.status, 0);
|
|
assert.strictEqual(child.signal, null);
|
|
assert.match(stdout, /# tests 2/);
|
|
assert.match(stdout, /# suites 2/);
|
|
assert.match(stdout, /# pass 2/);
|
|
assert.match(stdout, /ok 1 - suite one/);
|
|
assert.match(stdout, /ok 1 - suite one - test/);
|
|
assert.match(stdout, /ok 2 - suite two/);
|
|
assert.match(stdout, /ok 1 - suite two - test/);
|
|
});
|
|
|
|
test('works without --test-only', () => {
|
|
const args = [
|
|
'--test',
|
|
'--test-reporter=tap',
|
|
'--test-isolation=none',
|
|
fixture1,
|
|
fixture2,
|
|
];
|
|
const child = spawnSync(process.execPath, args);
|
|
const stdout = child.stdout.toString();
|
|
|
|
assert.strictEqual(child.status, 0);
|
|
assert.strictEqual(child.signal, null);
|
|
assert.match(stdout, /# tests 2/);
|
|
assert.match(stdout, /# suites 2/);
|
|
assert.match(stdout, /# pass 2/);
|
|
assert.match(stdout, /ok 1 - suite one/);
|
|
assert.match(stdout, /ok 1 - suite one - test/);
|
|
assert.match(stdout, /ok 2 - suite two/);
|
|
assert.match(stdout, /ok 1 - suite two - test/);
|
|
});
|
|
|
|
test('works with --test-name-pattern', () => {
|
|
const args = [
|
|
'--test',
|
|
'--test-reporter=tap',
|
|
'--test-isolation=none',
|
|
'--test-name-pattern=/test one/',
|
|
fixture1,
|
|
fixture2,
|
|
];
|
|
const child = spawnSync(process.execPath, args);
|
|
const stdout = child.stdout.toString();
|
|
|
|
assert.strictEqual(child.status, 0);
|
|
assert.strictEqual(child.signal, null);
|
|
assert.match(stdout, /# tests 0/);
|
|
assert.match(stdout, /# suites 0/);
|
|
});
|
|
|
|
test('filtered suites with an async build do not leave cancelled tests', () => {
|
|
const args = [
|
|
'--test',
|
|
'--test-reporter=tap',
|
|
'--test-isolation=none',
|
|
'--test-name-pattern=C',
|
|
asyncBuildFilteredSuite,
|
|
];
|
|
const child = spawnSync(process.execPath, args);
|
|
const stdout = child.stdout.toString();
|
|
|
|
assert.strictEqual(child.status, 0);
|
|
assert.strictEqual(child.signal, null);
|
|
assert.match(stdout, /# tests 1/);
|
|
assert.match(stdout, /# suites 2/);
|
|
assert.match(stdout, /# pass 1/);
|
|
assert.match(stdout, /# fail 0/);
|
|
assert.match(stdout, /# cancelled 0/);
|
|
assert.doesNotMatch(stdout, /parentAlreadyFinished/);
|
|
});
|
|
|
|
test('works with --test-skip-pattern', () => {
|
|
const args = [
|
|
'--test',
|
|
'--test-reporter=tap',
|
|
'--test-isolation=none',
|
|
'--test-skip-pattern=/one/',
|
|
fixture1,
|
|
fixture2,
|
|
];
|
|
const child = spawnSync(process.execPath, args);
|
|
const stdout = child.stdout.toString();
|
|
|
|
assert.strictEqual(child.status, 0);
|
|
assert.strictEqual(child.signal, null);
|
|
assert.match(stdout, /# tests 1/);
|
|
assert.match(stdout, /# suites 1/);
|
|
assert.match(stdout, /# pass 1/);
|
|
assert.match(stdout, /ok 1 - suite two - test/);
|
|
});
|