-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-test.ts
98 lines (78 loc) · 3.38 KB
/
run-test.ts
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
import assert from "assert/strict";
import { getTests, runTests } from "./src";
import { scheduledSuites, _clearScheduledTests } from "./src/scheduler";
async function runAssertionPassingTests() {
const tests = await getTests("./", /assertion-should-pass\.test\.ts$/);
const results = runTests(tests, { noExit: true, quiet: false });
return results;
}
async function runAssertionFailingTests() {
const tests = await getTests("./", /assertion-should-fail\.test\.ts$/);
const results = runTests(tests, { noExit: true, quiet: true });
return results;
}
async function runLifecycleFailingTests() {
const tests = await getTests("./", /lifecycle-should-fail\.test\.ts$/);
const results = runTests(tests, { noExit: true, quiet: true });
return results;
}
async function runSchedulerTests() {
const tests = await getTests("./", /scheduler\.test\.ts$/);
const results = runTests(tests, { noExit: true, quiet: false });
return results;
}
async function runToolsTests() {
const tests = await getTests("./", /tools\.test\.ts$/);
const results = runTests(tests, { noExit: true, quiet: false });
return results;
}
async function run() {
const assertionShouldPassResults = await runAssertionPassingTests();
assert.deepEqual(assertionShouldPassResults.stats.failCount, 0);
assert.deepEqual(assertionShouldPassResults.stats.warningCount, 0);
assert.deepEqual(assertionShouldPassResults.stats.suiteCount > 0, true);
assert.deepEqual(assertionShouldPassResults.stats.passCount > 0, true);
_clearScheduledTests();
const assertionsShouldFailResults = await runAssertionFailingTests();
assert.deepEqual(assertionsShouldFailResults.stats.failCount > 0, true);
assert.deepEqual(assertionsShouldFailResults.stats.warningCount, 0);
assert.deepEqual(assertionsShouldFailResults.stats.suiteCount > 0, true);
assert.deepEqual(assertionsShouldFailResults.stats.passCount, 0);
_clearScheduledTests();
const lifecycleResults = await runLifecycleFailingTests();
assert.deepEqual(lifecycleResults.stats.failCount, 0);
// we set up one warning per spec
assert.deepEqual(lifecycleResults.stats.warningCount, 4);
assert.deepEqual(lifecycleResults.stats.suiteCount > 0, true);
assert.deepEqual(lifecycleResults.stats.passCount, 4);
_clearScheduledTests();
const toolsTestsResults = await runToolsTests();
assert.deepEqual(toolsTestsResults.stats.failCount, 0);
assert.deepEqual(toolsTestsResults.stats.warningCount, 0);
assert.deepEqual(toolsTestsResults.stats.suiteCount > 0, true);
assert.deepEqual(toolsTestsResults.stats.passCount > 0, true);
_clearScheduledTests();
const schedulerResults = await runSchedulerTests();
assert.deepEqual(schedulerResults.stats.failCount, 0);
assert.deepEqual(schedulerResults.stats.warningCount, 0);
assert.deepEqual(schedulerResults.stats.suiteCount > 0, true);
assert.deepEqual(schedulerResults.stats.passCount > 0, true);
console.log(
`${
assertionShouldPassResults.stats.failCount +
assertionShouldPassResults.stats.warningCount
} assertion should-pass tests failed`
);
console.log(
`${assertionsShouldFailResults.stats.passCount} assertion should-fail tests passed`
);
console.log(
`${lifecycleResults.stats.warningCount} lifecycle issues successfully reported`
);
console.log(
`${
schedulerResults.stats.failCount + schedulerResults.stats.warningCount
} scheduler tests failed`
);
}
run();