Repository navigation
Expand file tree
/
Copy pathtest-runner-no-isolation-filtering.js
More file actions
115 lines (104 loc) Β· 3.35 KB
/
Copy pathtest-runner-no-isolation-filtering.js
File metadata and controls
115 lines (104 loc) Β· 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
'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/);
});