sxy-test-runner 2.4.2 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +55 -9
- package/dist/cli/help.js +6 -4
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/index.js +3 -23
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init.js +1 -0
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/lib/agentReport.d.ts +1 -1
- package/dist/cli/lib/agentReport.js +5 -0
- package/dist/cli/lib/agentReport.js.map +1 -1
- package/dist/cli/lib/defaultConfig.js +1 -0
- package/dist/cli/lib/defaultConfig.js.map +1 -1
- package/dist/cli/lib/parseCommandLineArguments.d.ts +1 -0
- package/dist/cli/lib/parseCommandLineArguments.js +15 -1
- package/dist/cli/lib/parseCommandLineArguments.js.map +1 -1
- package/dist/cli/lib/resolveCommand.d.ts +8 -0
- package/dist/cli/lib/resolveCommand.js +47 -0
- package/dist/cli/lib/resolveCommand.js.map +1 -0
- package/dist/cli/lib/runDescribe.d.ts +2 -1
- package/dist/cli/lib/runDescribe.js +5 -2
- package/dist/cli/lib/runDescribe.js.map +1 -1
- package/dist/cli/lib/runDescribeRun.d.ts +2 -1
- package/dist/cli/lib/runDescribeRun.js +8 -2
- package/dist/cli/lib/runDescribeRun.js.map +1 -1
- package/dist/cli/lib/runTest.d.ts +2 -1
- package/dist/cli/lib/runTest.js +6 -2
- package/dist/cli/lib/runTest.js.map +1 -1
- package/dist/cli/lib/runTests.js +19 -4
- package/dist/cli/lib/runTests.js.map +1 -1
- package/dist/cli/lib/showTestResult.js +13 -2
- package/dist/cli/lib/showTestResult.js.map +1 -1
- package/dist/cli/lib/stopSignal.d.ts +7 -0
- package/dist/cli/lib/stopSignal.js +10 -0
- package/dist/cli/lib/stopSignal.js.map +1 -0
- package/dist/cli/once.js +33 -11
- package/dist/cli/once.js.map +1 -1
- package/dist/cli/watch.js +3 -0
- package/dist/cli/watch.js.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.js.map +1 -1
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runDescribeRun.js","sourceRoot":"","sources":["../../../src/cli/lib/runDescribeRun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"runDescribeRun.js","sourceRoot":"","sources":["../../../src/cli/lib/runDescribeRun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAA;AAMjF,MAAM,UAAU,cAAc,CAC1B,MAAmB,EACnB,QAAkB,EAClB,SAAyB,EACzB,OAAmB,cAAc,EAAE;IAEnC,OAAO,gBAAgB,CAAC,yBAAyB,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,IAAI,EAAE;QAC1E,MAAM,EAAE,GAAG,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,SAAS,CAAA;QAE1G,MAAM,gBAAgB,GAAG,QAAQ,CAAC,IAAI,KAAK,SAAS;YAChD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,eAAe,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,QAAQ,CA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QAAQ,CAAC,KAAK;YACrB,OAAO,EAAE,CAAC,gBAAgB,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,KAAK,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YACjG,IAAI,EAAE,CAAC,EAAE,6BAA6B;YACtC,SAAS;YACT,gBAAgB;SACnB,CAAA;QAED,YAAY;QACZ,IAAI,OAAO,iBAAiB,KAAK,UAAU;YAAE,MAAM,iBAAiB,EAAE,CAAA;QACtE,MAAM,uBAAuB,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;QAE5D,OAAO,cAAc,CAAA;IACzB,CAAC,CAAC,CAAA;AACN,CAAC;AAED,KAAK,UAAU,uBAAuB,CAAC,MAAmB,EAAE,OAAoB;IAC5E,IAAI,MAAM,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;AACL,CAAC","sourcesContent":["import { timeProfileAsync } from './timeProfier.js'\nimport { runTasks } from './runTasks.js'\nimport { debug } from '../../output.js'\nimport { runIt } from './runIt.js'\n\nimport { makeStopSignal, stopIfFailFast, type StopSignal } from './stopSignal.js'\n\nimport type {\n FinalConfig, Describe, DescribeResult, ItResult, ItResultsSummary, ParsedDescribe, TaskExports\n} from '../../types.js'\n\nexport function runDescribeRun(\n config: FinalConfig,\n describe: Describe,\n parsedIts: ParsedDescribe,\n stop: StopSignal = makeStopSignal()\n): Promise<DescribeResult> {\n return timeProfileAsync(`run describe, run its ${describe.thing}`, async () => {\n const { its, beforeDescribeExports, afterDescribeFunc, beforeEachTestFunc, afterEachTestFunc } = parsedIts\n\n const parallelOverride = describe.meta === undefined\n ? undefined\n : 'parallelTests' in describe.meta ? describe.meta.parallelTests : !describe.meta.sequentialTests\n\n const isParallel = parallelOverride ?? config.execution.tests === 'parallel'\n\n const itPromises: Array<Promise<ItResult>> = []\n for (const it of its) {\n // checked before starting, so the failing test is the last one that runs\n if (stop.stopped) break\n const itPromise = runIt(config, it, beforeEachTestFunc, afterEachTestFunc)\n itPromises.push(itPromise)\n if (!isParallel) stopIfFailFast(config, stop, (await itPromise).success === false)\n }\n const itResults = await Promise.all(itPromises)\n\n // in parallel mode the tests are already in flight, so this only stops later work\n stopIfFailFast(config, stop, itResults.some(itResult => itResult.success === false))\n\n const itResultsSummary: ItResultsSummary = {\n total: 0,\n passes: 0\n }\n\n for (const itResult of itResults) {\n itResultsSummary.total += +(itResult.success !== null)\n itResultsSummary.passes += +(itResult.success ?? false)\n }\n\n debug('itResultsSummary', itResultsSummary)\n\n const describeResult: DescribeResult = {\n counter: describe.counter,\n thing: describe.thing,\n success: (itResultsSummary.total > 0) ? itResultsSummary.passes === itResultsSummary.total : null,\n time: 0, // overwritten by runDescribe\n itResults,\n itResultsSummary\n }\n\n // run after\n if (typeof afterDescribeFunc === 'function') await afterDescribeFunc()\n await configAfterEachDescribe(config, beforeDescribeExports)\n\n return describeResult\n })\n}\n\nasync function configAfterEachDescribe(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.afterEachDescribe !== undefined) {\n await runTasks(config.afterEachDescribe, exports)\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type StopSignal } from './stopSignal.js';
|
|
1
2
|
import type { FinalConfig, TestExecutionFilters, TestFile, TestResult } from '../../types.js';
|
|
2
|
-
export declare function runTest(config: FinalConfig, test: TestFile, filters?: TestExecutionFilters): Promise<TestResult>;
|
|
3
|
+
export declare function runTest(config: FinalConfig, test: TestFile, filters?: TestExecutionFilters, stop?: StopSignal): Promise<TestResult>;
|
|
3
4
|
//# sourceMappingURL=runTest.d.ts.map
|
package/dist/cli/lib/runTest.js
CHANGED
|
@@ -4,8 +4,9 @@ import { showTimeProfiling } from '../../config.js';
|
|
|
4
4
|
import { runTasks } from './runTasks.js';
|
|
5
5
|
import { addExports } from './addExports.js';
|
|
6
6
|
import { runDescribe } from './runDescribe.js';
|
|
7
|
+
import { makeStopSignal } from './stopSignal.js';
|
|
7
8
|
const { timeProfileAsync } = createTimeProfiler(showTimeProfiling);
|
|
8
|
-
export function runTest(config, test, filters = {}) {
|
|
9
|
+
export function runTest(config, test, filters = {}, stop = makeStopSignal()) {
|
|
9
10
|
return timeProfileAsync(`run test ${test.file}`, async () => {
|
|
10
11
|
debug('test', test);
|
|
11
12
|
// run before test file
|
|
@@ -17,10 +18,13 @@ export function runTest(config, test, filters = {}) {
|
|
|
17
18
|
const isParallel = parallelOverride ?? config.execution.describes === 'parallel';
|
|
18
19
|
const runDescribePromises = [];
|
|
19
20
|
for (const describe of test.describes ?? []) {
|
|
21
|
+
// a failure in an earlier describe leaves the rest of the file unrun
|
|
22
|
+
if (stop.stopped)
|
|
23
|
+
break;
|
|
20
24
|
if (filters.describe !== undefined
|
|
21
25
|
&& !describe.thing.toLowerCase().includes(filters.describe.toLowerCase()))
|
|
22
26
|
continue;
|
|
23
|
-
const describePromise = runDescribe(config, describe, filters.it);
|
|
27
|
+
const describePromise = runDescribe(config, describe, filters.it, stop);
|
|
24
28
|
runDescribePromises.push(describePromise);
|
|
25
29
|
if (!isParallel)
|
|
26
30
|
await describePromise;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runTest.js","sourceRoot":"","sources":["../../../src/cli/lib/runTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"runTest.js","sourceRoot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,IAAI,CAAC,CAAA;YACpE,sBAAsB,CAAC,QAAQ,IAAI,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAA;YACxE,sBAAsB,CAAC,SAAS,IAAI,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAA;QAC9E,CAAC;QAED,MAAM,WAAW,GAAe;YAC5B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,CAAC,sBAAsB,CAAC,KAAK,GAAG,CAAC,CAAC;gBACvC,CAAC,CAAC,sBAAsB,CAAC,KAAK,KAAK,sBAAsB,CAAC,MAAM;gBAChE,CAAC,CAAC,IAAI;YACV,eAAe;YACf,sBAAsB;YACtB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;SACxB,CAAA;QAED,iBAAiB;QACjB,MAAM,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAE9C,OAAO,WAAW,CAAA;IACtB,CAAC,CAAC,CAAA;AACN,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,MAAmB,EAAE,OAAoB;IACzE,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,CAAA;QACnE,IAAI,UAAU;YAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IACnD,CAAC;AACL,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,MAAmB,EAAE,OAAoB;IACxE,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;AACL,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { debug } from '../../output.js'\nimport { showTimeProfiling } from '../../config.js'\n\nimport { runTasks } from './runTasks.js'\nimport { addExports } from './addExports.js'\nimport { runDescribe } from './runDescribe.js'\n\nimport { makeStopSignal, stopIfFailFast, type StopSignal } from './stopSignal.js'\n\nimport type {\n FinalConfig, DescribeResult, DescribeResultsSummary, TaskExports, TestExecutionFilters, TestFile, TestResult\n} from '../../types.js'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport function runTest(\n config: FinalConfig,\n test: TestFile,\n filters: TestExecutionFilters = {},\n stop: StopSignal = makeStopSignal()\n): Promise<TestResult> {\n return timeProfileAsync(`run test ${test.file}`, async () => {\n debug('test', test)\n\n // run before test file\n const fileExports: TaskExports = {}\n await configBeforeEachFile(config, fileExports)\n\n const parallelOverride = test.meta === undefined\n ? undefined\n : 'parallelDescribes' in test.meta ? test.meta.parallelDescribes : !test.meta.sequentialDescribes\n\n const isParallel = parallelOverride ?? config.execution.describes === 'parallel'\n\n const runDescribePromises: Array<Promise<DescribeResult>> = []\n\n for (const describe of test.describes ?? []) {\n // a failure in an earlier describe leaves the rest of the file unrun\n if (stop.stopped) break\n\n if (\n filters.describe !== undefined\n && !describe.thing.toLowerCase().includes(filters.describe.toLowerCase())\n ) continue\n\n const describePromise = runDescribe(config, describe, filters.it, stop)\n runDescribePromises.push(describePromise)\n if (!isParallel) await describePromise\n }\n\n let describeResults = await Promise.all(runDescribePromises)\n if (filters.it !== undefined) {\n describeResults = describeResults.filter(result => (\n result.itResults.length > 0 || result.error !== undefined\n ))\n }\n\n const describeResultsSummary: DescribeResultsSummary = {\n total: 0,\n passes: 0,\n invalid: 0,\n itsTotal: 0,\n itsPasses: 0\n }\n\n for (const describeResult of describeResults) {\n describeResultsSummary.total += +(describeResult.success !== null)\n describeResultsSummary.passes += +(describeResult.success ?? false)\n describeResultsSummary.invalid += +(describeResult.success === null)\n describeResultsSummary.itsTotal += describeResult.itResultsSummary.total\n describeResultsSummary.itsPasses += describeResult.itResultsSummary.passes\n }\n\n const testResults: TestResult = {\n file: test.file,\n success: (describeResultsSummary.total > 0)\n ? describeResultsSummary.total === describeResultsSummary.passes\n : null,\n describeResults,\n describeResultsSummary,\n logs: test.logs ?? []\n }\n\n // run after test\n await configAfterEachFile(config, fileExports)\n\n return testResults\n })\n}\n\nasync function configBeforeEachFile(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.beforeEachFile !== undefined) {\n const theExports = await runTasks(config.beforeEachFile, undefined)\n if (theExports) addExports(exports, theExports)\n }\n}\n\nasync function configAfterEachFile(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.afterEachFile !== undefined) {\n await runTasks(config.afterEachFile, exports)\n }\n}\n"]}
|
package/dist/cli/lib/runTests.js
CHANGED
|
@@ -12,6 +12,7 @@ import { showTestResult } from './showTestResult.js';
|
|
|
12
12
|
import { failureLines } from './failureLines.js';
|
|
13
13
|
import { failureEntries } from './failureEntries.js';
|
|
14
14
|
import { agentDone, agentFailure, agentRunStart } from './agentReport.js';
|
|
15
|
+
import { makeStopSignal, stopIfFailFast } from './stopSignal.js';
|
|
15
16
|
import { statusCodes, writeStatusFile } from './statusFile.js';
|
|
16
17
|
import { makeRunManagerState } from './makeWatchRunState.js';
|
|
17
18
|
const { timeProfileAsync } = createTimeProfiler(showTimeProfiling);
|
|
@@ -32,6 +33,7 @@ export async function runTests(config, testFiles, reRunManager, refresh = 'refre
|
|
|
32
33
|
const state = reRunManager?.state || makeRunManagerState();
|
|
33
34
|
const runStartTime = new Date().getTime();
|
|
34
35
|
const agentRun = agentRunStart(config, testFiles.size);
|
|
36
|
+
const stop = makeStopSignal();
|
|
35
37
|
//console.log('new runTests:', watchRunState?.activeRuns)
|
|
36
38
|
//console.log(inspect(testFiles))
|
|
37
39
|
try {
|
|
@@ -43,14 +45,18 @@ export async function runTests(config, testFiles, reRunManager, refresh = 'refre
|
|
|
43
45
|
for (const testFile of testFiles) {
|
|
44
46
|
//console.log('testFiles', testFiles)
|
|
45
47
|
//console.log('testFile', testFile)
|
|
48
|
+
// an earlier file failed under failFast - leave the rest unloaded
|
|
49
|
+
if (stop.stopped)
|
|
50
|
+
break;
|
|
46
51
|
const test = await loadTestFile(config, testFile, refresh);
|
|
47
52
|
if (test.error !== undefined && test.error !== false) {
|
|
48
53
|
erroringTests[testFile] = test;
|
|
49
54
|
state.failedTestFiles.add(testFile);
|
|
50
55
|
showTestLoadingError(config, test, customOut);
|
|
56
|
+
stopIfFailFast(config, stop, true);
|
|
51
57
|
}
|
|
52
58
|
else {
|
|
53
|
-
const testRunPromise = runTest(config, test, filters);
|
|
59
|
+
const testRunPromise = runTest(config, test, filters, stop);
|
|
54
60
|
testRunPromises[testFile] = testRunPromise;
|
|
55
61
|
testRunOutPromises[testFile] = testRunPromise.then(async (testResult) => {
|
|
56
62
|
if (testResult.success === true || testResult.success === null) {
|
|
@@ -185,10 +191,18 @@ export async function runTests(config, testFiles, reRunManager, refresh = 'refre
|
|
|
185
191
|
else {
|
|
186
192
|
out(chalk.mediumred(`${testFilesText}`) + testFilesDetailsSuffix);
|
|
187
193
|
}
|
|
194
|
+
// the tallies only cover what ran, so say the run was cut short - otherwise
|
|
195
|
+
// "Tests: 0/1" reads as a one test suite
|
|
196
|
+
const stoppedPlain = (stop.stopped)
|
|
197
|
+
? 'stopped at the first failure (failFast)'
|
|
198
|
+
: '';
|
|
199
|
+
if (stoppedPlain !== '')
|
|
200
|
+
out(chalk.orange(stoppedPlain));
|
|
188
201
|
const summaryLines = [
|
|
189
202
|
testsText,
|
|
190
203
|
joinPlain(describesText, invalidDescribesPlain, describesThrownPlain),
|
|
191
|
-
joinPlain(testFilesText, invalidTestFilesPlain, failedToLoadPlain)
|
|
204
|
+
joinPlain(testFilesText, invalidTestFilesPlain, failedToLoadPlain),
|
|
205
|
+
...(stoppedPlain === '') ? [] : [stoppedPlain]
|
|
192
206
|
];
|
|
193
207
|
const durationMs = new Date().getTime() - runStartTime;
|
|
194
208
|
if (allPassed) {
|
|
@@ -201,11 +215,12 @@ export async function runTests(config, testFiles, reRunManager, refresh = 'refre
|
|
|
201
215
|
// partway - a different problem from tests that ran and failed
|
|
202
216
|
const aborted = abortedFiles.length > 0 || describesThrownCount > 0;
|
|
203
217
|
const failedTestsCount = testsResultsSummary.itsTotal - testsResultsSummary.itsPasses;
|
|
204
|
-
const description = [
|
|
218
|
+
const description = ([
|
|
205
219
|
plural(abortedFiles.length, 'test file', 'failed to load or errored'),
|
|
206
220
|
plural(describesThrownCount, 'describe', 'errored'),
|
|
207
221
|
plural(failedTestsCount, 'test', 'failed')
|
|
208
|
-
].filter(part => part !== '').join(', ') || 'test run failed'
|
|
222
|
+
].filter(part => part !== '').join(', ') || 'test run failed')
|
|
223
|
+
+ ((stop.stopped) ? ', stopped at the first failure' : '');
|
|
209
224
|
const code = (aborted) ? statusCodes.aborted : statusCodes.failed;
|
|
210
225
|
const failures = failureEntries(Object.values(runTestResults), erroringTests);
|
|
211
226
|
writeStatusFile(config, code, description, [...summaryLines, ...failureLines(Object.values(runTestResults), erroringTests)], durationMs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runTests.js","sourceRoot":"","sources":["../../../src/cli/lib/runTests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAA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AAC,IAAI,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAA;gBAE7D,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAA;gBACjE,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,CAAA;gBAE7E,eAAe,CACX,MAAM,EACN,IAAI,EACJ,WAAW,EACX,CAAC,GAAG,YAAY,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,CAAC,EAChF,UAAU,CACb,CAAA;gBAED,mEAAmE;gBACnE,KAAK,MAAM,OAAO,IAAI,QAAQ;oBAAE,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;gBACvE,SAAS,CACL,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mBAAmB,EAAE,UAAU,EACpE,KAAK,CAAC,eAAe,CAAC,IAAI,CAC7B,CAAA;YACL,CAAC;YAED,gBAAgB;YAChB,uDAAuD;YACvD,OAAO,SAAS,CAAA;QACpB,CAAC,CAAC,CAAA;IACN,CAAC;YAAS,CAAC;QACP,IAAI,YAAY,KAAK,SAAS;YAAE,YAAY,CAAC,KAAK,CAAC,UAAU,EAAE,CAAA;IACnE,CAAC;AACL,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport chalk from '../../packages/chalk.js'\nimport { out as mainOut } from '../../output.js'\nimport figures from '../../packages/figures.js'\nimport { count } from 'sxy-lib/objects.js'\nimport { remove as arrayRemove } from 'sxy-lib/arrays.js'\nimport { allObj as promiseAllObj } from 'sxy-lib/promises.js'\n\nimport { loadTestFile } from './loadTestFile.js'\nimport { runTest } from './runTest.js'\nimport { showTestLoadingError } from './showTestLoadingError.js'\nimport { showTestResult } from './showTestResult.js'\nimport { failureLines } from './failureLines.js'\nimport { failureEntries } from './failureEntries.js'\nimport { agentDone, agentFailure, agentRunStart } from './agentReport.js'\nimport { statusCodes, writeStatusFile } from './statusFile.js'\n\nimport type {\n FinalConfig, OutFn, TestExecutionFilters, TestFile, TestResult, TestsResultsSummary\n} from '../../types.js'\nimport { makeRunManagerState, ReRunManageState } from './makeWatchRunState.js'\nimport { ReRunManager } from './reRunManager.js'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport type RunTestsPromise = Promise<boolean | null>\n\n// the summary lines, minus the colouring, for the status file\nfunction joinPlain(...parts: string[]): string {\n return parts.filter(part => part !== '').join(' ')\n}\n\nfunction plural(count: number, noun: string, verb: string): string {\n if (count < 1) return ''\n return `${count} ${noun}${count === 1 ? '' : 's'} ${verb}`\n}\n\n\nexport async function runTests(\n config: FinalConfig,\n testFiles: Set<string>,\n reRunManager: ReRunManager | undefined,\n refresh: 'refresh' | 'cached' = 'refresh',\n customOut?: OutFn,\n filters: TestExecutionFilters = {}\n): RunTestsPromise {\n if (reRunManager !== undefined) {\n reRunManager.state.lastTestFiles = new Set(testFiles)\n reRunManager.state.activeRuns++ // whatever, obsolete. Can use it to check on things\n }\n\n const state = reRunManager?.state || makeRunManagerState()\n const runStartTime = new Date().getTime()\n const agentRun = agentRunStart(config, testFiles.size)\n //console.log('new runTests:', watchRunState?.activeRuns)\n //console.log(inspect(testFiles))\n\n try {\n const testRunPromises: Record<string, Promise<TestResult>> = {}\n const erroringTests: Record<string, TestFile> = {}\n const testRunOutPromises: Record<string, Promise<void>> = {}\n\n await timeProfileAsync('run tests', async () => {\n if (Array.isArray(testFiles) ? testFiles.length > 0 : testFiles.size > 0) {\n for (const testFile of testFiles) {\n //console.log('testFiles', testFiles)\n //console.log('testFile', testFile)\n const test = await loadTestFile(config, testFile, refresh)\n\n if (test.error !== undefined && test.error !== false) {\n erroringTests[testFile] = test\n state.failedTestFiles.add(testFile)\n showTestLoadingError(config, test, customOut)\n } else {\n const testRunPromise = runTest(config, test, filters)\n testRunPromises[testFile] = testRunPromise\n\n testRunOutPromises[testFile] = testRunPromise.then(async testResult => {\n if (testResult.success === true || testResult.success === null) {\n state.failedTestFiles.delete(testResult.file)\n } else {\n state.failedTestFiles.add(testFile)\n }\n const executionFilterActive = filters.describe !== undefined || filters.it !== undefined\n if (!executionFilterActive || testResult.describeResultsSummary.itsTotal > 0) {\n await showTestResult(config, testResult, customOut)\n }\n })\n\n // wait for the test to complete before proceeding if we are in 'sequential' mode\n if (config.execution.files === 'sequential') await testRunOutPromises[testFile]\n }\n }\n }\n })\n\n let runTestResults: Record<string, TestResult> = {}\n\n await timeProfileAsync('wait for tests to finish', async () => {\n runTestResults = await promiseAllObj(testRunPromises)\n\n // wait for the output to complete\n await promiseAllObj(testRunOutPromises)\n })\n\n return await timeProfileAsync('show initial test run results', () => {\n \n const out = customOut ?? mainOut\n\n const testsResultsSummary: TestsResultsSummary = {\n total: 0,\n passes: 0,\n invalid: 0,\n describesTotal: 0,\n describesPasses: 0,\n describesInvalid: 0,\n itsTotal: 0,\n itsPasses: 0\n // itsInvalid: 0 // we don't check whether tests run any asserts (we don't control the assertion lib)\n }\n let describesThrownCount = 0\n\n for (const testFile in runTestResults) {\n const runTestResult = runTestResults[testFile]\n if (!runTestResult) continue\n\n testsResultsSummary.total += +(runTestResult.success !== null)\n testsResultsSummary.passes += +(runTestResult.success ?? false)\n testsResultsSummary.invalid += +(runTestResult.success === null)\n testsResultsSummary.describesTotal += runTestResult.describeResultsSummary.total\n testsResultsSummary.describesPasses += runTestResult.describeResultsSummary.passes\n testsResultsSummary.describesInvalid += runTestResult.describeResultsSummary.invalid\n testsResultsSummary.itsTotal += runTestResult.describeResultsSummary.itsTotal\n testsResultsSummary.itsPasses += runTestResult.describeResultsSummary.itsPasses\n describesThrownCount += runTestResult.describeResults\n .filter(describeResult => describeResult.error !== undefined)\n .length\n }\n\n const failedToLoadCount = count(erroringTests)\n testsResultsSummary.total += failedToLoadCount\n\n if (\n (filters.describe !== undefined || filters.it !== undefined)\n && testsResultsSummary.itsTotal === 0\n && failedToLoadCount === 0\n && describesThrownCount === 0\n ) {\n out(chalk.orange('No tests matched the describe/test filters.'))\n const durationMs = new Date().getTime() - runStartTime\n writeStatusFile(\n config,\n statusCodes.couldNotRun,\n 'no tests matched the describe/test filters',\n [],\n durationMs\n )\n agentDone(\n config, agentRun, statusCodes.couldNotRun,\n 'no tests matched the describe/test filters', testsResultsSummary, durationMs,\n state.failedTestFiles.size\n )\n return null\n }\n\n out('\\n')\n\n const allPassed = (\n testsResultsSummary.passes === testsResultsSummary.total\n && testsResultsSummary.describesPasses === testsResultsSummary.describesTotal\n && testsResultsSummary.itsPasses === testsResultsSummary.itsTotal\n )\n\n if (allPassed) {\n out(chalk.mediumgreen(`${figures.tick}`))\n } else {\n out(chalk.mediumred(`${figures.cross}`))\n }\n\n // number of tests successful\n const testsText = `Tests: ${testsResultsSummary.itsPasses}/${testsResultsSummary.itsTotal}`\n if (testsResultsSummary.itsPasses === testsResultsSummary.itsTotal) {\n out(chalk.mediumgreen(`${testsText}`))\n } else {\n out(chalk.mediumred(`${testsText}`))\n }\n\n // number of items successful\n const describesText = `Items: ${testsResultsSummary.describesPasses}/${testsResultsSummary.describesTotal}`\n const invalidDescribesPlain = (testsResultsSummary.describesInvalid >= 1)\n ? (testsResultsSummary.describesInvalid === 1)\n ? '(+1 describe without tests)'\n : `(+${testsResultsSummary.describesInvalid} describes without tests)`\n : ''\n const describesThrownPlain = (describesThrownCount >= 1)\n ? (describesThrownCount === 1)\n ? '(1 describe errored)'\n : `(${describesThrownCount} describes errored)`\n : ''\n const describesDetailsText = [\n chalk.grey(invalidDescribesPlain), chalk.mediumred(describesThrownPlain)\n ]\n .filter(text => text !== '')\n .join(' ')\n const describesDetailsSuffix = describesDetailsText === '' ? '' : ` ${describesDetailsText}`\n if (testsResultsSummary.describesPasses === testsResultsSummary.describesTotal) {\n out(chalk.mediumgreen(`${describesText}`) + describesDetailsSuffix)\n } else {\n out(chalk.mediumred(`${describesText}`) + describesDetailsSuffix)\n }\n\n // number of test files successful\n const testFilesText = `Test Files: ${testsResultsSummary.passes}/${testsResultsSummary.total}`\n const invalidTestFilesPlain = (testsResultsSummary.invalid >= 1)\n ? (testsResultsSummary.invalid === 1)\n ? '(+1 file without tests)'\n : `(+${testsResultsSummary.invalid} files without tests)`\n : ''\n const failedToLoadPlain = (failedToLoadCount >= 1)\n ? (failedToLoadCount === 1)\n ? '(1 file failed to load, or errored)'\n : `(${failedToLoadCount} files failed to load, or errored)`\n : ''\n const testFilesDetailsText = [\n chalk.grey(invalidTestFilesPlain), chalk.mediumred(failedToLoadPlain)\n ]\n .filter(text => text !== '')\n .join(' ')\n const testFilesDetailsSuffix = testFilesDetailsText === '' ? '' : ` ${testFilesDetailsText}`\n if (testsResultsSummary.passes === testsResultsSummary.total) {\n out(chalk.mediumgreen(`${testFilesText}`) + testFilesDetailsSuffix)\n } else {\n out(chalk.mediumred(`${testFilesText}`) + testFilesDetailsSuffix)\n }\n\n const summaryLines = [\n testsText,\n joinPlain(describesText, invalidDescribesPlain, describesThrownPlain),\n joinPlain(testFilesText, invalidTestFilesPlain, failedToLoadPlain)\n ]\n\n const durationMs = new Date().getTime() - runStartTime\n\n if (allPassed) {\n writeStatusFile(\n config, statusCodes.passed, 'all tests passed', summaryLines, durationMs\n )\n agentDone(\n config, agentRun, statusCodes.passed, 'all tests passed',\n testsResultsSummary, durationMs, state.failedTestFiles.size\n )\n } else {\n const abortedFiles = Object.keys(erroringTests)\n\n // a file that would not load, or a describe that threw, means the run died\n // partway - a different problem from tests that ran and failed\n const aborted = abortedFiles.length > 0 || describesThrownCount > 0\n const failedTestsCount = testsResultsSummary.itsTotal - testsResultsSummary.itsPasses\n\n const description = [\n plural(abortedFiles.length, 'test file', 'failed to load or errored'),\n plural(describesThrownCount, 'describe', 'errored'),\n plural(failedTestsCount, 'test', 'failed')\n ].filter(part => part !== '').join(', ') || 'test run failed'\n\n const code = (aborted) ? statusCodes.aborted : statusCodes.failed\n const failures = failureEntries(Object.values(runTestResults), erroringTests)\n\n writeStatusFile(\n config,\n code,\n description,\n [...summaryLines, ...failureLines(Object.values(runTestResults), erroringTests)],\n durationMs\n )\n\n // failures first, so the done line is a complete end of run marker\n for (const failure of failures) agentFailure(config, agentRun, failure)\n agentDone(\n config, agentRun, code, description, testsResultsSummary, durationMs,\n state.failedTestFiles.size\n )\n }\n\n // full success?\n // true/false gets returned to the caller of runTests()\n return allPassed\n })\n } finally {\n if (reRunManager !== undefined) reRunManager.state.activeRuns--\n }\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"runTests.js","sourceRoot":"","sources":["../../../src/cli/lib/runTests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzE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YACL,CAAC;YAED,gBAAgB;YAChB,uDAAuD;YACvD,OAAO,SAAS,CAAA;QACpB,CAAC,CAAC,CAAA;IACN,CAAC;YAAS,CAAC;QACP,IAAI,YAAY,KAAK,SAAS;YAAE,YAAY,CAAC,KAAK,CAAC,UAAU,EAAE,CAAA;IACnE,CAAC;AACL,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport chalk from '../../packages/chalk.js'\nimport { out as mainOut } from '../../output.js'\nimport figures from '../../packages/figures.js'\nimport { count } from 'sxy-lib/objects.js'\nimport { remove as arrayRemove } from 'sxy-lib/arrays.js'\nimport { allObj as promiseAllObj } from 'sxy-lib/promises.js'\n\nimport { loadTestFile } from './loadTestFile.js'\nimport { runTest } from './runTest.js'\nimport { showTestLoadingError } from './showTestLoadingError.js'\nimport { showTestResult } from './showTestResult.js'\nimport { failureLines } from './failureLines.js'\nimport { failureEntries } from './failureEntries.js'\nimport { agentDone, agentFailure, agentRunStart } from './agentReport.js'\nimport { makeStopSignal, stopIfFailFast } from './stopSignal.js'\nimport { statusCodes, writeStatusFile } from './statusFile.js'\n\nimport type {\n FinalConfig, OutFn, TestExecutionFilters, TestFile, TestResult, TestsResultsSummary\n} from '../../types.js'\nimport { makeRunManagerState, ReRunManageState } from './makeWatchRunState.js'\nimport { ReRunManager } from './reRunManager.js'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport type RunTestsPromise = Promise<boolean | null>\n\n// the summary lines, minus the colouring, for the status file\nfunction joinPlain(...parts: string[]): string {\n return parts.filter(part => part !== '').join(' ')\n}\n\nfunction plural(count: number, noun: string, verb: string): string {\n if (count < 1) return ''\n return `${count} ${noun}${count === 1 ? '' : 's'} ${verb}`\n}\n\n\nexport async function runTests(\n config: FinalConfig,\n testFiles: Set<string>,\n reRunManager: ReRunManager | undefined,\n refresh: 'refresh' | 'cached' = 'refresh',\n customOut?: OutFn,\n filters: TestExecutionFilters = {}\n): RunTestsPromise {\n if (reRunManager !== undefined) {\n reRunManager.state.lastTestFiles = new Set(testFiles)\n reRunManager.state.activeRuns++ // whatever, obsolete. Can use it to check on things\n }\n\n const state = reRunManager?.state || makeRunManagerState()\n const runStartTime = new Date().getTime()\n const agentRun = agentRunStart(config, testFiles.size)\n const stop = makeStopSignal()\n //console.log('new runTests:', watchRunState?.activeRuns)\n //console.log(inspect(testFiles))\n\n try {\n const testRunPromises: Record<string, Promise<TestResult>> = {}\n const erroringTests: Record<string, TestFile> = {}\n const testRunOutPromises: Record<string, Promise<void>> = {}\n\n await timeProfileAsync('run tests', async () => {\n if (Array.isArray(testFiles) ? testFiles.length > 0 : testFiles.size > 0) {\n for (const testFile of testFiles) {\n //console.log('testFiles', testFiles)\n //console.log('testFile', testFile)\n\n // an earlier file failed under failFast - leave the rest unloaded\n if (stop.stopped) break\n\n const test = await loadTestFile(config, testFile, refresh)\n\n if (test.error !== undefined && test.error !== false) {\n erroringTests[testFile] = test\n state.failedTestFiles.add(testFile)\n showTestLoadingError(config, test, customOut)\n stopIfFailFast(config, stop, true)\n } else {\n const testRunPromise = runTest(config, test, filters, stop)\n testRunPromises[testFile] = testRunPromise\n\n testRunOutPromises[testFile] = testRunPromise.then(async testResult => {\n if (testResult.success === true || testResult.success === null) {\n state.failedTestFiles.delete(testResult.file)\n } else {\n state.failedTestFiles.add(testFile)\n }\n const executionFilterActive = filters.describe !== undefined || filters.it !== undefined\n if (!executionFilterActive || testResult.describeResultsSummary.itsTotal > 0) {\n await showTestResult(config, testResult, customOut)\n }\n })\n\n // wait for the test to complete before proceeding if we are in 'sequential' mode\n if (config.execution.files === 'sequential') await testRunOutPromises[testFile]\n }\n }\n }\n })\n\n let runTestResults: Record<string, TestResult> = {}\n\n await timeProfileAsync('wait for tests to finish', async () => {\n runTestResults = await promiseAllObj(testRunPromises)\n\n // wait for the output to complete\n await promiseAllObj(testRunOutPromises)\n })\n\n return await timeProfileAsync('show initial test run results', () => {\n \n const out = customOut ?? mainOut\n\n const testsResultsSummary: TestsResultsSummary = {\n total: 0,\n passes: 0,\n invalid: 0,\n describesTotal: 0,\n describesPasses: 0,\n describesInvalid: 0,\n itsTotal: 0,\n itsPasses: 0\n // itsInvalid: 0 // we don't check whether tests run any asserts (we don't control the assertion lib)\n }\n let describesThrownCount = 0\n\n for (const testFile in runTestResults) {\n const runTestResult = runTestResults[testFile]\n if (!runTestResult) continue\n\n testsResultsSummary.total += +(runTestResult.success !== null)\n testsResultsSummary.passes += +(runTestResult.success ?? false)\n testsResultsSummary.invalid += +(runTestResult.success === null)\n testsResultsSummary.describesTotal += runTestResult.describeResultsSummary.total\n testsResultsSummary.describesPasses += runTestResult.describeResultsSummary.passes\n testsResultsSummary.describesInvalid += runTestResult.describeResultsSummary.invalid\n testsResultsSummary.itsTotal += runTestResult.describeResultsSummary.itsTotal\n testsResultsSummary.itsPasses += runTestResult.describeResultsSummary.itsPasses\n describesThrownCount += runTestResult.describeResults\n .filter(describeResult => describeResult.error !== undefined)\n .length\n }\n\n const failedToLoadCount = count(erroringTests)\n testsResultsSummary.total += failedToLoadCount\n\n if (\n (filters.describe !== undefined || filters.it !== undefined)\n && testsResultsSummary.itsTotal === 0\n && failedToLoadCount === 0\n && describesThrownCount === 0\n ) {\n out(chalk.orange('No tests matched the describe/test filters.'))\n const durationMs = new Date().getTime() - runStartTime\n writeStatusFile(\n config,\n statusCodes.couldNotRun,\n 'no tests matched the describe/test filters',\n [],\n durationMs\n )\n agentDone(\n config, agentRun, statusCodes.couldNotRun,\n 'no tests matched the describe/test filters', testsResultsSummary, durationMs,\n state.failedTestFiles.size\n )\n return null\n }\n\n out('\\n')\n\n const allPassed = (\n testsResultsSummary.passes === testsResultsSummary.total\n && testsResultsSummary.describesPasses === testsResultsSummary.describesTotal\n && testsResultsSummary.itsPasses === testsResultsSummary.itsTotal\n )\n\n if (allPassed) {\n out(chalk.mediumgreen(`${figures.tick}`))\n } else {\n out(chalk.mediumred(`${figures.cross}`))\n }\n\n // number of tests successful\n const testsText = `Tests: ${testsResultsSummary.itsPasses}/${testsResultsSummary.itsTotal}`\n if (testsResultsSummary.itsPasses === testsResultsSummary.itsTotal) {\n out(chalk.mediumgreen(`${testsText}`))\n } else {\n out(chalk.mediumred(`${testsText}`))\n }\n\n // number of items successful\n const describesText = `Items: ${testsResultsSummary.describesPasses}/${testsResultsSummary.describesTotal}`\n const invalidDescribesPlain = (testsResultsSummary.describesInvalid >= 1)\n ? (testsResultsSummary.describesInvalid === 1)\n ? '(+1 describe without tests)'\n : `(+${testsResultsSummary.describesInvalid} describes without tests)`\n : ''\n const describesThrownPlain = (describesThrownCount >= 1)\n ? (describesThrownCount === 1)\n ? '(1 describe errored)'\n : `(${describesThrownCount} describes errored)`\n : ''\n const describesDetailsText = [\n chalk.grey(invalidDescribesPlain), chalk.mediumred(describesThrownPlain)\n ]\n .filter(text => text !== '')\n .join(' ')\n const describesDetailsSuffix = describesDetailsText === '' ? '' : ` ${describesDetailsText}`\n if (testsResultsSummary.describesPasses === testsResultsSummary.describesTotal) {\n out(chalk.mediumgreen(`${describesText}`) + describesDetailsSuffix)\n } else {\n out(chalk.mediumred(`${describesText}`) + describesDetailsSuffix)\n }\n\n // number of test files successful\n const testFilesText = `Test Files: ${testsResultsSummary.passes}/${testsResultsSummary.total}`\n const invalidTestFilesPlain = (testsResultsSummary.invalid >= 1)\n ? (testsResultsSummary.invalid === 1)\n ? '(+1 file without tests)'\n : `(+${testsResultsSummary.invalid} files without tests)`\n : ''\n const failedToLoadPlain = (failedToLoadCount >= 1)\n ? (failedToLoadCount === 1)\n ? '(1 file failed to load, or errored)'\n : `(${failedToLoadCount} files failed to load, or errored)`\n : ''\n const testFilesDetailsText = [\n chalk.grey(invalidTestFilesPlain), chalk.mediumred(failedToLoadPlain)\n ]\n .filter(text => text !== '')\n .join(' ')\n const testFilesDetailsSuffix = testFilesDetailsText === '' ? '' : ` ${testFilesDetailsText}`\n if (testsResultsSummary.passes === testsResultsSummary.total) {\n out(chalk.mediumgreen(`${testFilesText}`) + testFilesDetailsSuffix)\n } else {\n out(chalk.mediumred(`${testFilesText}`) + testFilesDetailsSuffix)\n }\n\n // the tallies only cover what ran, so say the run was cut short - otherwise\n // \"Tests: 0/1\" reads as a one test suite\n const stoppedPlain = (stop.stopped)\n ? 'stopped at the first failure (failFast)'\n : ''\n if (stoppedPlain !== '') out(chalk.orange(stoppedPlain))\n\n const summaryLines = [\n testsText,\n joinPlain(describesText, invalidDescribesPlain, describesThrownPlain),\n joinPlain(testFilesText, invalidTestFilesPlain, failedToLoadPlain),\n ...(stoppedPlain === '') ? [] : [stoppedPlain]\n ]\n\n const durationMs = new Date().getTime() - runStartTime\n\n if (allPassed) {\n writeStatusFile(\n config, statusCodes.passed, 'all tests passed', summaryLines, durationMs\n )\n agentDone(\n config, agentRun, statusCodes.passed, 'all tests passed',\n testsResultsSummary, durationMs, state.failedTestFiles.size\n )\n } else {\n const abortedFiles = Object.keys(erroringTests)\n\n // a file that would not load, or a describe that threw, means the run died\n // partway - a different problem from tests that ran and failed\n const aborted = abortedFiles.length > 0 || describesThrownCount > 0\n const failedTestsCount = testsResultsSummary.itsTotal - testsResultsSummary.itsPasses\n\n const description = ([\n plural(abortedFiles.length, 'test file', 'failed to load or errored'),\n plural(describesThrownCount, 'describe', 'errored'),\n plural(failedTestsCount, 'test', 'failed')\n ].filter(part => part !== '').join(', ') || 'test run failed')\n + ((stop.stopped) ? ', stopped at the first failure' : '')\n\n const code = (aborted) ? statusCodes.aborted : statusCodes.failed\n const failures = failureEntries(Object.values(runTestResults), erroringTests)\n\n writeStatusFile(\n config,\n code,\n description,\n [...summaryLines, ...failureLines(Object.values(runTestResults), erroringTests)],\n durationMs\n )\n\n // failures first, so the done line is a complete end of run marker\n for (const failure of failures) agentFailure(config, agentRun, failure)\n agentDone(\n config, agentRun, code, description, testsResultsSummary, durationMs,\n state.failedTestFiles.size\n )\n }\n\n // full success?\n // true/false gets returned to the caller of runTests()\n return allPassed\n })\n } finally {\n if (reRunManager !== undefined) reRunManager.state.activeRuns--\n }\n}\n\n"]}
|
|
@@ -21,6 +21,16 @@ function alignMessage(message, spacer) {
|
|
|
21
21
|
? [line]
|
|
22
22
|
: (line.trim()) ? [...previous, spacer + line] : previous, []).join('\n');
|
|
23
23
|
}
|
|
24
|
+
// A multi line string is shown as text, indented under its label. inspect() would render it
|
|
25
|
+
// as one quoted chunk per line joined with `+`, which buries the content it is there to
|
|
26
|
+
// show. Everything else - objects, and single line strings, whose quotes reveal padding and
|
|
27
|
+
// emptiness - still goes through inspect.
|
|
28
|
+
function showValue(value, column) {
|
|
29
|
+
if (typeof value !== 'string' || !value.includes('\n')) {
|
|
30
|
+
return inspect(value, { depth: 5 });
|
|
31
|
+
}
|
|
32
|
+
return value.split('\n').join(`\n${column}`);
|
|
33
|
+
}
|
|
24
34
|
export async function showTestResult(config, testResult, customOut) {
|
|
25
35
|
const out = customOut ?? mainOut;
|
|
26
36
|
await timeProfileAsync('show test result', () => {
|
|
@@ -92,8 +102,9 @@ export async function showTestResult(config, testResult, customOut) {
|
|
|
92
102
|
out(chalk.mediumred(`${spacer}Assertion Failed: ${alignMessage(err.message, spacer)}`));
|
|
93
103
|
// shown whenever the error carries them, so a falsy actual or
|
|
94
104
|
// expected - 0, '', false, null - still gets its diff
|
|
95
|
-
|
|
96
|
-
|
|
105
|
+
const valueColumn = `${spacer} `;
|
|
106
|
+
out(_chalk.yellow `${spacer}Actual ${showValue(err.actual, valueColumn)}\n`
|
|
107
|
+
+ _chalk.blueBright `${spacer}Expected ${showValue(err.expected, valueColumn)}`);
|
|
97
108
|
}
|
|
98
109
|
else {
|
|
99
110
|
out(chalk.mediumred(`${spacer}${err.name}: ${alignMessage(err.message, spacer)}`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"showTestResult.js","sourceRoot":"","sources":["../../../src/cli/lib/showTestResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,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J,GAAG,CAAC,KAAK,CAAC,SAAS,CACf,GAAG,MAAM,GAAG,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAC/D,CAAC,CAAA;wBACN,CAAC;wBACD,cAAc;wBACd,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;4BACxB,GAAG,EAAE,CAAA;4BACL,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAA;wBACpC,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED,GAAG,EAAE,CAAA;gBACL,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC3B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAA,eAAe,CAAC,CAAA;oBAC9B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;wBACxB,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;oBACf,CAAC,CAAC,CAAA;oBACF,GAAG,EAAE,CAAA;gBACT,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAA;AACN,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport _chalk from 'chalk'\nimport chalk from '../../packages/chalk.js'\nimport { out as mainOut } from '../../output.js'\nimport figures from '../../packages/figures.js'\nimport { indexNumberToLetters } from '../../indexNumberToLetters.js'\n\nimport type { FinalConfig, OutFn, TestError, TestResult } from '../../types.js'\nimport { inspect } from 'node:util'\n\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\n// Assertion failures are recognised by shape, not by where they came from. Importing an\n// assertion library to test `instanceof` against cannot work here: the runner would need it\n// as a dependency, and the copy a test file throws from is a separate ESM instance anyway,\n// so the check fails for the very errors it is meant to catch.\nfunction isAssertionLike(error: TestError): boolean {\n return 'actual' in error || 'expected' in error\n}\n\n// Node's assertion messages run to several lines. Later lines are indented to the message\n// column and blank ones dropped; a single line message passes through untouched.\nfunction alignMessage(message: string, spacer: string): string {\n return message.split('\\n').reduce<string[]>(\n (previous, line) => (previous.length === 0)\n ? [line]\n : (line.trim()) ? [...previous, spacer + line] : previous,\n []\n ).join('\\n')\n}\n\nexport async function showTestResult(config: FinalConfig, testResult: TestResult, customOut?: OutFn): Promise<void> {\n const out = customOut ?? mainOut\n\n await timeProfileAsync('show test result', () => {\n out()\n out(chalk.grey`File ${testResult.file}`)\n\n const indent = ' '\n\n if (testResult.logs.length > 0) {\n out()\n out(chalk.grey`console.logs:`)\n testResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n\n let first = true\n\n for (const describeResult of testResult.describeResults) {\n if (!first) out()\n first = false\n\n out(chalk.lightgrey`${describeResult.counter}) describing ` + chalk.brightblue(describeResult.thing)\n + chalk.grey` ${describeResult.time.toLocaleString()}ms`)\n out()\n\n if (describeResult.logs && describeResult.logs.length > 0) {\n out(chalk.grey`console.logs:`)\n describeResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n\n if (describeResult.error !== undefined) {\n const describeError = describeResult.error\n const describeErrorText = (\n typeof describeError === 'object'\n && describeError !== null\n && 'name' in describeError\n && 'message' in describeError\n && typeof describeError.name === 'string'\n && typeof describeError.message === 'string'\n )\n ? `${describeError.name}: ${describeError.message}`\n : String(describeError) // eslint-disable-line @typescript-eslint/no-base-to-string -- only a fallback, if it gives poor results, change it\n\n out(chalk.mediumred(`${indent}Threw:`))\n out(chalk.mediumred(`${indent}${describeErrorText}`))\n if (config.showErrorTrace) {\n const describeErrorStack = (\n typeof describeError === 'object'\n && describeError !== null\n && 'stack' in describeError\n && typeof describeError.stack === 'string'\n )\n ? describeError.stack\n : ''\n out()\n out(chalk.grey(describeErrorStack))\n }\n out()\n }\n\n for (const itResult of describeResult.itResults) {\n const letters = indexNumberToLetters(itResult.counter) ?? ''\n const itTime = chalk.grey` ${itResult.time.toLocaleString()}ms`\n if (itResult.success === true) {\n out(chalk.lightgrey`${indent}${letters})`\n + chalk.mediumgreen` ${figures.tick} ${itResult.should}` + itTime)\n } else {\n out(chalk.lightgrey`${indent}${letters})`\n + chalk.mediumred` ${figures.cross} ${itResult.should}` + itTime)\n out()\n const spacer = `${indent}${' '.repeat(letters.length)} `\n const err = itResult.error\n if (err) {\n if (isAssertionLike(err)) {\n out(chalk.mediumred(\n `${spacer}Assertion Failed: ${alignMessage(err.message, spacer)}`\n ))\n // shown whenever the error carries them, so a falsy actual or\n // expected - 0, '', false, null - still gets its diff\n out(\n _chalk.yellow`${spacer}Actual ${inspect(err.actual, { depth: 5 })}\\n`\n + _chalk.blueBright`${spacer}Expected ${inspect(err.expected, { depth: 5 })}`\n )\n } else {\n out(chalk.mediumred(\n `${spacer}${err.name}: ${alignMessage(err.message, spacer)}`\n ))\n }\n // stack trace\n if (config.showErrorTrace) {\n out()\n out(chalk.grey(err.stack ?? ''))\n }\n }\n }\n\n out()\n if (itResult.logs.length > 0) {\n out(chalk.grey`console.logs:`)\n itResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n }\n }\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"showTestResult.js","sourceRoot":"","sources":["../../../src/cli/lib/showTestResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,MAAM,MAAM,OAAO,CAAA;AAC1B,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAGpE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,MAAM,EAAE,gBAAgB,EAAE,GAA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CAAC;6BAAM,CAAC;4BACJ,GAAG,CAAC,KAAK,CAAC,SAAS,CACf,GAAG,MAAM,GAAG,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAC/D,CAAC,CAAA;wBACN,CAAC;wBACD,cAAc;wBACd,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;4BACxB,GAAG,EAAE,CAAA;4BACL,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAA;wBACpC,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED,GAAG,EAAE,CAAA;gBACL,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC3B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAA,eAAe,CAAC,CAAA;oBAC9B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;wBACxB,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;oBACf,CAAC,CAAC,CAAA;oBACF,GAAG,EAAE,CAAA;gBACT,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAA;AACN,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport _chalk from 'chalk'\nimport chalk from '../../packages/chalk.js'\nimport { out as mainOut } from '../../output.js'\nimport figures from '../../packages/figures.js'\nimport { indexNumberToLetters } from '../../indexNumberToLetters.js'\n\nimport type { FinalConfig, OutFn, TestError, TestResult } from '../../types.js'\nimport { inspect } from 'node:util'\n\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\n// Assertion failures are recognised by shape, not by where they came from. Importing an\n// assertion library to test `instanceof` against cannot work here: the runner would need it\n// as a dependency, and the copy a test file throws from is a separate ESM instance anyway,\n// so the check fails for the very errors it is meant to catch.\nfunction isAssertionLike(error: TestError): boolean {\n return 'actual' in error || 'expected' in error\n}\n\n// Node's assertion messages run to several lines. Later lines are indented to the message\n// column and blank ones dropped; a single line message passes through untouched.\nfunction alignMessage(message: string, spacer: string): string {\n return message.split('\\n').reduce<string[]>(\n (previous, line) => (previous.length === 0)\n ? [line]\n : (line.trim()) ? [...previous, spacer + line] : previous,\n []\n ).join('\\n')\n}\n\n// A multi line string is shown as text, indented under its label. inspect() would render it\n// as one quoted chunk per line joined with `+`, which buries the content it is there to\n// show. Everything else - objects, and single line strings, whose quotes reveal padding and\n// emptiness - still goes through inspect.\nfunction showValue(value: unknown, column: string): string {\n if (typeof value !== 'string' || !value.includes('\\n')) {\n return inspect(value, { depth: 5 })\n }\n return value.split('\\n').join(`\\n${column}`)\n}\n\nexport async function showTestResult(config: FinalConfig, testResult: TestResult, customOut?: OutFn): Promise<void> {\n const out = customOut ?? mainOut\n\n await timeProfileAsync('show test result', () => {\n out()\n out(chalk.grey`File ${testResult.file}`)\n\n const indent = ' '\n\n if (testResult.logs.length > 0) {\n out()\n out(chalk.grey`console.logs:`)\n testResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n\n let first = true\n\n for (const describeResult of testResult.describeResults) {\n if (!first) out()\n first = false\n\n out(chalk.lightgrey`${describeResult.counter}) describing ` + chalk.brightblue(describeResult.thing)\n + chalk.grey` ${describeResult.time.toLocaleString()}ms`)\n out()\n\n if (describeResult.logs && describeResult.logs.length > 0) {\n out(chalk.grey`console.logs:`)\n describeResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n\n if (describeResult.error !== undefined) {\n const describeError = describeResult.error\n const describeErrorText = (\n typeof describeError === 'object'\n && describeError !== null\n && 'name' in describeError\n && 'message' in describeError\n && typeof describeError.name === 'string'\n && typeof describeError.message === 'string'\n )\n ? `${describeError.name}: ${describeError.message}`\n : String(describeError) // eslint-disable-line @typescript-eslint/no-base-to-string -- only a fallback, if it gives poor results, change it\n\n out(chalk.mediumred(`${indent}Threw:`))\n out(chalk.mediumred(`${indent}${describeErrorText}`))\n if (config.showErrorTrace) {\n const describeErrorStack = (\n typeof describeError === 'object'\n && describeError !== null\n && 'stack' in describeError\n && typeof describeError.stack === 'string'\n )\n ? describeError.stack\n : ''\n out()\n out(chalk.grey(describeErrorStack))\n }\n out()\n }\n\n for (const itResult of describeResult.itResults) {\n const letters = indexNumberToLetters(itResult.counter) ?? ''\n const itTime = chalk.grey` ${itResult.time.toLocaleString()}ms`\n if (itResult.success === true) {\n out(chalk.lightgrey`${indent}${letters})`\n + chalk.mediumgreen` ${figures.tick} ${itResult.should}` + itTime)\n } else {\n out(chalk.lightgrey`${indent}${letters})`\n + chalk.mediumred` ${figures.cross} ${itResult.should}` + itTime)\n out()\n const spacer = `${indent}${' '.repeat(letters.length)} `\n const err = itResult.error\n if (err) {\n if (isAssertionLike(err)) {\n out(chalk.mediumred(\n `${spacer}Assertion Failed: ${alignMessage(err.message, spacer)}`\n ))\n // shown whenever the error carries them, so a falsy actual or\n // expected - 0, '', false, null - still gets its diff\n const valueColumn = `${spacer} `\n out(\n _chalk.yellow`${spacer}Actual ${showValue(err.actual, valueColumn)}\\n`\n + _chalk.blueBright`${spacer}Expected ${showValue(err.expected, valueColumn)}`\n )\n } else {\n out(chalk.mediumred(\n `${spacer}${err.name}: ${alignMessage(err.message, spacer)}`\n ))\n }\n // stack trace\n if (config.showErrorTrace) {\n out()\n out(chalk.grey(err.stack ?? ''))\n }\n }\n }\n\n out()\n if (itResult.logs.length > 0) {\n out(chalk.grey`console.logs:`)\n itResult.logs.forEach(log => {\n out(...log)\n })\n out()\n }\n }\n }\n })\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FinalConfig } from '../../types.js';
|
|
2
|
+
export interface StopSignal {
|
|
3
|
+
stopped: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function makeStopSignal(): StopSignal;
|
|
6
|
+
export declare function stopIfFailFast(config: FinalConfig, stop: StopSignal, failed: boolean): void;
|
|
7
|
+
//# sourceMappingURL=stopSignal.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function makeStopSignal() {
|
|
2
|
+
return { stopped: false };
|
|
3
|
+
}
|
|
4
|
+
// `failed` covers all three: a test file that would not load, a describe that threw, and a
|
|
5
|
+
// test that failed
|
|
6
|
+
export function stopIfFailFast(config, stop, failed) {
|
|
7
|
+
if (config.failFast && failed)
|
|
8
|
+
stop.stopped = true;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=stopSignal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stopSignal.js","sourceRoot":"","sources":["../../../src/cli/lib/stopSignal.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,cAAc;IAC1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC;AAED,2FAA2F;AAC3F,mBAAmB;AACnB,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,IAAgB,EAAE,MAAe;IACjF,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM;QAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;AACtD,CAAC","sourcesContent":["import type { FinalConfig } from '../../types.js'\n\n// Shared by one run, so the file, describe and test loops can all see that something has\n// failed and stop starting new work. Deliberately a signal the loops *check* rather than an\n// exception: breaking out leaves every afterEach/teardown to unwind as it normally would.\nexport interface StopSignal {\n stopped: boolean\n}\n\nexport function makeStopSignal(): StopSignal {\n return { stopped: false }\n}\n\n// `failed` covers all three: a test file that would not load, a describe that threw, and a\n// test that failed\nexport function stopIfFailFast(config: FinalConfig, stop: StopSignal, failed: boolean): void {\n if (config.failFast && failed) stop.stopped = true\n}\n"]}
|
package/dist/cli/once.js
CHANGED
|
@@ -6,7 +6,6 @@ import { findingTestsMessage } from './lib/findingTestsMessage.js';
|
|
|
6
6
|
import { foundTestsMessage } from './lib/foundTestsMessage.js';
|
|
7
7
|
import { isTest } from './lib/isTest.js';
|
|
8
8
|
export async function once() {
|
|
9
|
-
out(chalk.brightblue `[${packageName}]...`);
|
|
10
9
|
const startTime = new Date().getTime();
|
|
11
10
|
const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js');
|
|
12
11
|
const allowedClArguments = {
|
|
@@ -29,10 +28,26 @@ export async function once() {
|
|
|
29
28
|
'filter-describe': {
|
|
30
29
|
flag: 'd',
|
|
31
30
|
hasValue: true
|
|
31
|
+
},
|
|
32
|
+
'fail-fast': {
|
|
33
|
+
flag: 'x',
|
|
34
|
+
hasValue: false
|
|
35
|
+
},
|
|
36
|
+
'agent': {
|
|
37
|
+
hasValue: false
|
|
32
38
|
}
|
|
33
39
|
};
|
|
34
40
|
const clArguments = parseCommandLineArguments(allowedClArguments);
|
|
35
41
|
//debug('clArguments', clArguments)
|
|
42
|
+
// agent mode owns stdout: the usual per-test output is routed into a sink, leaving the
|
|
43
|
+
// failures and the summary. Announced before the config loads, as in watch mode.
|
|
44
|
+
const agentMode = clArguments.agent === true;
|
|
45
|
+
const { agentInit, agentFound, agentRunStart, agentDone, agentSetRunReason, agentSilentOut } = await import('./lib/agentReport.js');
|
|
46
|
+
agentInit(agentMode);
|
|
47
|
+
agentSetRunReason('once');
|
|
48
|
+
const agentOut = (agentMode) ? agentSilentOut : out;
|
|
49
|
+
const runsOut = (agentMode) ? agentSilentOut : undefined;
|
|
50
|
+
agentOut(chalk.brightblue `[${packageName}]...`);
|
|
36
51
|
setEnv();
|
|
37
52
|
const { loadConfig } = await import('./lib/loadConfig.js');
|
|
38
53
|
const userConfig = (typeof clArguments.config === 'string')
|
|
@@ -63,9 +78,10 @@ export async function once() {
|
|
|
63
78
|
}
|
|
64
79
|
const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js');
|
|
65
80
|
const config = applyConfigDefaults(userConfig);
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
config.
|
|
81
|
+
// both flags are the only source: assigned rather than or'd, so a config file cannot
|
|
82
|
+
// silently truncate every run, or swap the output format out from under a caller
|
|
83
|
+
config.failFast = clArguments['fail-fast'] === true;
|
|
84
|
+
config.watch.agent = agentMode;
|
|
69
85
|
const { validateConfig } = await import('./lib/validateConfig.js');
|
|
70
86
|
validateConfig(config);
|
|
71
87
|
//console.log('run setup')
|
|
@@ -73,34 +89,40 @@ export async function once() {
|
|
|
73
89
|
const { doUserSetup } = await import('./lib/doUserSetup.js');
|
|
74
90
|
await doUserSetup(config);
|
|
75
91
|
//console.log('ran setup')
|
|
76
|
-
|
|
92
|
+
agentOut(chalk.brightblue(findingTestsMessage(config)));
|
|
77
93
|
const { findTestFiles } = await import('./lib/findTestFiles.js');
|
|
78
94
|
const testFiles = await findTestFiles(config);
|
|
95
|
+
agentFound(config, testFiles.size);
|
|
79
96
|
if (testFiles.size === 0) {
|
|
80
|
-
|
|
97
|
+
agentOut(chalk.mediumred(`[${packageName}] Found no tests.`
|
|
81
98
|
+ '\nCreate tests matching the patterns, '
|
|
82
99
|
+ `\nor set new patterns in ${configFileNames.map(x => `${x}.js/cjs/mjs`).join(' or ')}`));
|
|
83
100
|
const endTime = new Date().getTime();
|
|
84
101
|
const time = endTime - startTime;
|
|
85
|
-
|
|
102
|
+
agentOut(chalk.brightblue(`[${packageName}] time: ${time.toLocaleString()}ms`));
|
|
103
|
+
// reported as a run, so a reader waiting on a done line always gets one
|
|
104
|
+
const { statusCodes } = await import('./lib/statusFile.js');
|
|
105
|
+
const run = agentRunStart(config, 0);
|
|
106
|
+
agentDone(config, run, statusCodes.couldNotRun, 'no test files found', null, time, 0);
|
|
86
107
|
// setup has already run by this point, so teardown must run too, or its side
|
|
87
108
|
// effects are left behind
|
|
88
109
|
const { doUserTeardown } = await import('./lib/doUserTeardown.js');
|
|
89
110
|
await doUserTeardown(config);
|
|
90
111
|
process.exit(4);
|
|
91
112
|
}
|
|
92
|
-
|
|
113
|
+
agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)));
|
|
93
114
|
// testFiles.size is guaranteed non-zero here - the no-tests case exited above
|
|
94
115
|
const { runTests } = await import('./lib/runTests.js');
|
|
95
|
-
|
|
96
|
-
|
|
116
|
+
if (!agentMode)
|
|
117
|
+
log(chalk.brightblue `running tests...`);
|
|
118
|
+
const testsResult = await runTests(config, testFiles, undefined, (isTest) ? 'refresh' : 'cached', runsOut, {
|
|
97
119
|
it: filterIt,
|
|
98
120
|
describe: filterDescribe
|
|
99
121
|
});
|
|
100
122
|
// 5 - not 4 - so callers can tell "no test files matched" from "filters matched nothing"
|
|
101
123
|
const exitCode = testsResult === null ? 5 : testsResult ? 0 : 3;
|
|
102
124
|
const time = new Date().getTime() - startTime;
|
|
103
|
-
|
|
125
|
+
agentOut(chalk.grey `\n${time.toLocaleString()}ms\n`);
|
|
104
126
|
const { doUserTeardown } = await import('./lib/doUserTeardown.js');
|
|
105
127
|
await doUserTeardown(config);
|
|
106
128
|
process.exit(exitCode);
|
package/dist/cli/once.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/cli/once.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAGxC,MAAM,CAAC,KAAK,UAAU,IAAI;IACtB,GAAG,CAAC,KAAK,CAAC,UAAU,CAAA,IAAI,WAAW,MAAM,CAAC,CAAA;IAE1C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAEtC,MAAM,EAAE,yBAAyB,EAAE,GAA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K,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE/D,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAA;IAC7C,GAAG,CAAC,KAAK,CAAC,IAAI,CAAA,KAAK,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;IAE/C,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAClE,MAAM,cAAc,CAAC,MAAM,CAAC,CAAA;IAE5B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["\nimport chalk from '../packages/chalk.js'\n\nimport { packageName, configFileNames } from '../config.js'\nimport { out, log } from '../output.js'\n\nimport type { AllowedArguments } from '../types.js'\nimport { setEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\nimport { isTest } from './lib/isTest.js'\n\n\nexport async function once(): Promise<void> {\n out(chalk.brightblue`[${packageName}]...`)\n\n const startTime = new Date().getTime()\n\n const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js')\n const allowedClArguments: AllowedArguments = {\n config: {\n flag: 'c',\n hasValue: true\n },\n 'test-files': {\n flag: 't',\n hasValue: true\n },\n filter: {\n flag: 'f',\n hasValue: true\n },\n 'filter-it': {\n flag: 'i',\n hasValue: true\n },\n 'filter-describe': {\n flag: 'd',\n hasValue: true\n }\n }\n const clArguments = parseCommandLineArguments(allowedClArguments)\n //debug('clArguments', clArguments)\n\n setEnv()\n\n const { loadConfig } = await import('./lib/loadConfig.js')\n const userConfig = (typeof clArguments.config === 'string')\n ? await loadConfig(clArguments.config)\n : await loadConfig()\n\n if ('test-files' in clArguments) {\n const testFilesPattern = clArguments['test-files']\n if (typeof testFilesPattern !== 'string' || testFilesPattern === '') {\n throw new Error('No pattern specified for --test-files or -t argument')\n }\n //console.log('Looking for tests using pattern: ' + testFilesPattern) // eslint-disable-line no-console\n userConfig.tests = testFilesPattern\n }\n\n if ('filter' in clArguments) {\n const filter = clArguments.filter\n if (typeof filter !== 'string' || filter === '') {\n throw new Error('No pattern specified for --filter or -f argument')\n }\n //console.log('Filtering tests using pattern: ' + filter) // eslint-disable-line no-console\n userConfig.testsFilter = filter\n }\n\n const filterIt = clArguments['filter-it']\n const filterDescribe = clArguments['filter-describe']\n if (filterIt === true || filterIt === '') throw new Error('No substring specified for --filter-it')\n if (filterDescribe === true || filterDescribe === '') {\n throw new Error('No substring specified for --filter-describe')\n }\n\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\n const config = applyConfigDefaults(userConfig)\n // agent reporting is a watch mode concern - `once` already ends with an exit code, so a\n // config setting it must not leak in here\n config.watch.agent = false\n\n const { validateConfig } = await import('./lib/validateConfig.js')\n validateConfig(config)\n\n //console.log('run setup')\n //console.log(util.inspect(config))\n const { doUserSetup } = await import('./lib/doUserSetup.js')\n await doUserSetup(config)\n //console.log('ran setup')\n \n out(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n\n if (testFiles.size === 0) {\n out(chalk.mediumred(`[${packageName}] Found no tests.`\n + '\\nCreate tests matching the patterns, '\n + `\\nor set new patterns in ${configFileNames.map(x => `${x}.js/cjs/mjs`).join(' or ')}`))\n\n const endTime = new Date().getTime()\n const time = endTime - startTime\n out(chalk.brightblue(`[${packageName}] time: ${time.toLocaleString()}ms`))\n\n // setup has already run by this point, so teardown must run too, or its side\n // effects are left behind\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(4)\n }\n\n out(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n // testFiles.size is guaranteed non-zero here - the no-tests case exited above\n const { runTests } = await import('./lib/runTests.js')\n log(chalk.brightblue`running tests...`)\n const testsResult = await runTests(\n config, testFiles,\n undefined,\n (isTest) ? 'refresh' : 'cached',\n undefined,\n {\n it: filterIt,\n describe: filterDescribe\n }\n )\n // 5 - not 4 - so callers can tell \"no test files matched\" from \"filters matched nothing\"\n const exitCode = testsResult === null ? 5 : testsResult ? 0 : 3\n\n const time = new Date().getTime() - startTime\n out(chalk.grey`\\n${time.toLocaleString()}ms\\n`)\n\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(exitCode)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/cli/once.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAGxC,MAAM,CAAC,KAAK,UAAU,IAAI;IACtB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAEtC,MAAM,EAAE,yBAAyB,EAAE,GAAG,MAAM,MAAM,CAAC,oCAAoC,CAAC,CAAA;IACxF,MAAM,kBAAkB,GAAqB;QACzC,MAAM,EAAE;YACJ,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,YAAY,EAAE;YACV,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,MAAM,EAAE;YACJ,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,WAAW,EAAE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IAE5B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["\nimport chalk from '../packages/chalk.js'\n\nimport { packageName, configFileNames } from '../config.js'\nimport { out, log } from '../output.js'\n\nimport type { AllowedArguments, OutFn } from '../types.js'\nimport { setEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\nimport { isTest } from './lib/isTest.js'\n\n\nexport async function once(): Promise<void> {\n const startTime = new Date().getTime()\n\n const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js')\n const allowedClArguments: AllowedArguments = {\n config: {\n flag: 'c',\n hasValue: true\n },\n 'test-files': {\n flag: 't',\n hasValue: true\n },\n filter: {\n flag: 'f',\n hasValue: true\n },\n 'filter-it': {\n flag: 'i',\n hasValue: true\n },\n 'filter-describe': {\n flag: 'd',\n hasValue: true\n },\n 'fail-fast': {\n flag: 'x',\n hasValue: false\n },\n 'agent': {\n hasValue: false\n }\n }\n const clArguments = parseCommandLineArguments(allowedClArguments)\n //debug('clArguments', clArguments)\n\n // agent mode owns stdout: the usual per-test output is routed into a sink, leaving the\n // failures and the summary. Announced before the config loads, as in watch mode.\n const agentMode = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentSetRunReason, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentMode)\n agentSetRunReason('once')\n const agentOut: OutFn = (agentMode) ? agentSilentOut : out\n const runsOut = (agentMode) ? agentSilentOut : undefined\n\n agentOut(chalk.brightblue`[${packageName}]...`)\n\n setEnv()\n\n const { loadConfig } = await import('./lib/loadConfig.js')\n const userConfig = (typeof clArguments.config === 'string')\n ? await loadConfig(clArguments.config)\n : await loadConfig()\n\n if ('test-files' in clArguments) {\n const testFilesPattern = clArguments['test-files']\n if (typeof testFilesPattern !== 'string' || testFilesPattern === '') {\n throw new Error('No pattern specified for --test-files or -t argument')\n }\n //console.log('Looking for tests using pattern: ' + testFilesPattern) // eslint-disable-line no-console\n userConfig.tests = testFilesPattern\n }\n\n if ('filter' in clArguments) {\n const filter = clArguments.filter\n if (typeof filter !== 'string' || filter === '') {\n throw new Error('No pattern specified for --filter or -f argument')\n }\n //console.log('Filtering tests using pattern: ' + filter) // eslint-disable-line no-console\n userConfig.testsFilter = filter\n }\n\n const filterIt = clArguments['filter-it']\n const filterDescribe = clArguments['filter-describe']\n if (filterIt === true || filterIt === '') throw new Error('No substring specified for --filter-it')\n if (filterDescribe === true || filterDescribe === '') {\n throw new Error('No substring specified for --filter-describe')\n }\n\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\n const config = applyConfigDefaults(userConfig)\n // both flags are the only source: assigned rather than or'd, so a config file cannot\n // silently truncate every run, or swap the output format out from under a caller\n config.failFast = clArguments['fail-fast'] === true\n config.watch.agent = agentMode\n\n const { validateConfig } = await import('./lib/validateConfig.js')\n validateConfig(config)\n\n //console.log('run setup')\n //console.log(util.inspect(config))\n const { doUserSetup } = await import('./lib/doUserSetup.js')\n await doUserSetup(config)\n //console.log('ran setup')\n \n agentOut(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n agentFound(config, testFiles.size)\n\n if (testFiles.size === 0) {\n agentOut(chalk.mediumred(`[${packageName}] Found no tests.`\n + '\\nCreate tests matching the patterns, '\n + `\\nor set new patterns in ${configFileNames.map(x => `${x}.js/cjs/mjs`).join(' or ')}`))\n\n const endTime = new Date().getTime()\n const time = endTime - startTime\n agentOut(chalk.brightblue(`[${packageName}] time: ${time.toLocaleString()}ms`))\n\n // reported as a run, so a reader waiting on a done line always gets one\n const { statusCodes } = await import('./lib/statusFile.js')\n const run = agentRunStart(config, 0)\n agentDone(config, run, statusCodes.couldNotRun, 'no test files found', null, time, 0)\n\n // setup has already run by this point, so teardown must run too, or its side\n // effects are left behind\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(4)\n }\n\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n // testFiles.size is guaranteed non-zero here - the no-tests case exited above\n const { runTests } = await import('./lib/runTests.js')\n if (!agentMode) log(chalk.brightblue`running tests...`)\n const testsResult = await runTests(\n config, testFiles,\n undefined,\n (isTest) ? 'refresh' : 'cached',\n runsOut,\n {\n it: filterIt,\n describe: filterDescribe\n }\n )\n // 5 - not 4 - so callers can tell \"no test files matched\" from \"filters matched nothing\"\n const exitCode = testsResult === null ? 5 : testsResult ? 0 : 3\n\n const time = new Date().getTime() - startTime\n agentOut(chalk.grey`\\n${time.toLocaleString()}ms\\n`)\n\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(exitCode)\n}\n"]}
|
package/dist/cli/watch.js
CHANGED
|
@@ -88,6 +88,9 @@ export async function watch() {
|
|
|
88
88
|
const config = applyConfigDefaults(userConfig);
|
|
89
89
|
if (agentMode)
|
|
90
90
|
config.watch.agent = true;
|
|
91
|
+
// there is no watch flag for it, and a config file must not enable it here: a truncated
|
|
92
|
+
// run would still report covers=all, and failing files would drop out of `failing`
|
|
93
|
+
config.failFast = false;
|
|
91
94
|
// not silenced in agent mode - a config error is fatal, so losing the message is worse
|
|
92
95
|
// than breaking the one-line-per-event contract
|
|
93
96
|
const { validateConfig } = await import('./lib/validateConfig.js');
|