sxy-test-runner 2.5.1 → 2.5.3

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.
Files changed (55) hide show
  1. package/AGENTS.md +15 -1
  2. package/dist/cli/init.js +5 -0
  3. package/dist/cli/init.js.map +1 -1
  4. package/dist/cli/lib/addBasePath.js +1 -1
  5. package/dist/cli/lib/addBasePath.js.map +1 -1
  6. package/dist/cli/lib/buildDependencyTrees.d.ts +1 -1
  7. package/dist/cli/lib/buildDependencyTrees.js +2 -2
  8. package/dist/cli/lib/buildDependencyTrees.js.map +1 -1
  9. package/dist/cli/lib/defaultConfig.js +2 -0
  10. package/dist/cli/lib/defaultConfig.js.map +1 -1
  11. package/dist/cli/lib/failureEntries.d.ts +1 -1
  12. package/dist/cli/lib/failureEntries.js +11 -8
  13. package/dist/cli/lib/failureEntries.js.map +1 -1
  14. package/dist/cli/lib/parseDescribe.js +1 -1
  15. package/dist/cli/lib/parseDescribe.js.map +1 -1
  16. package/dist/cli/lib/runDescribe.js +1 -1
  17. package/dist/cli/lib/runDescribe.js.map +1 -1
  18. package/dist/cli/lib/runDescribeRun.js +1 -1
  19. package/dist/cli/lib/runDescribeRun.js.map +1 -1
  20. package/dist/cli/lib/runIt.js +1 -1
  21. package/dist/cli/lib/runIt.js.map +1 -1
  22. package/dist/cli/lib/runTests.js +9 -188
  23. package/dist/cli/lib/runTests.js.map +1 -1
  24. package/dist/cli/lib/setEnv.d.ts +1 -0
  25. package/dist/cli/lib/setEnv.js +11 -0
  26. package/dist/cli/lib/setEnv.js.map +1 -1
  27. package/dist/cli/lib/showFailuresColorized.d.ts +2 -0
  28. package/dist/cli/lib/showFailuresColorized.js +52 -0
  29. package/dist/cli/lib/showFailuresColorized.js.map +1 -0
  30. package/dist/cli/lib/showTestFileResult.d.ts +7 -0
  31. package/dist/cli/lib/{showTestResult.js → showTestFileResult.js} +15 -9
  32. package/dist/cli/lib/showTestFileResult.js.map +1 -0
  33. package/dist/cli/lib/showTestResultsSummary.d.ts +8 -0
  34. package/dist/cli/lib/showTestResultsSummary.js +213 -0
  35. package/dist/cli/lib/showTestResultsSummary.js.map +1 -0
  36. package/dist/cli/lib/timeProfiler.d.ts +3 -0
  37. package/dist/cli/lib/{timeProfier.js → timeProfiler.js} +1 -1
  38. package/dist/cli/lib/timeProfiler.js.map +1 -0
  39. package/dist/cli/lib/validateConfig.js +7 -0
  40. package/dist/cli/lib/validateConfig.js.map +1 -1
  41. package/dist/cli/once.js +2 -1
  42. package/dist/cli/once.js.map +1 -1
  43. package/dist/cli/watch.d.ts +1 -1
  44. package/dist/cli/watch.js +6 -4
  45. package/dist/cli/watch.js.map +1 -1
  46. package/dist/packages/timeProfiler.d.ts +1 -1
  47. package/dist/packages/timeProfiler.js.map +1 -1
  48. package/dist/types.d.ts +2 -0
  49. package/dist/types.js.map +1 -1
  50. package/package.json +2 -1
  51. package/readme.md +8 -1
  52. package/dist/cli/lib/showTestResult.d.ts +0 -4
  53. package/dist/cli/lib/showTestResult.js.map +0 -1
  54. package/dist/cli/lib/timeProfier.d.ts +0 -3
  55. package/dist/cli/lib/timeProfier.js.map +0 -1
@@ -0,0 +1,213 @@
1
+ import { count } from 'sxy-lib/objects.js';
2
+ import chalk from '../../packages/chalk.js';
3
+ import figures from '../../packages/figures.js';
4
+ import { agentDone, agentFailure } from './agentReport.js';
5
+ import { failureEntries } from './failureEntries.js';
6
+ import { failureLines } from './failureLines.js';
7
+ //import { showFailures } from './showFailures.js'
8
+ import { showTestFileResult } from './showTestFileResult.js';
9
+ import { showTestLoadingError } from './showTestLoadingError.js';
10
+ import { writeStatusFile, statusCodes } from './statusFile.js';
11
+ import { out as mainOut } from '../../output.js';
12
+ import { timeProfile } from './timeProfiler.js';
13
+ // the summary lines, minus the colouring, for the status file
14
+ function joinPlain(...parts) {
15
+ return parts.filter(part => part !== '').join(' ');
16
+ }
17
+ function plural(count, noun, verb) {
18
+ if (count < 1)
19
+ return '';
20
+ return `${count} ${noun}${count === 1 ? '' : 's'} ${verb}`;
21
+ }
22
+ export function showTestResultsSummary(runTestResults, erroringTests, runStartTime, config, runNumber, state, stop, filters, customOut) {
23
+ return timeProfile('show test run result summary', () => {
24
+ const out = customOut ?? mainOut;
25
+ const testsResultsSummary = {
26
+ total: 0,
27
+ passes: 0,
28
+ invalid: 0,
29
+ describesTotal: 0,
30
+ describesPasses: 0,
31
+ describesInvalid: 0,
32
+ itsTotal: 0,
33
+ itsPasses: 0
34
+ // itsInvalid: 0 // we don't check whether tests run any asserts (we don't control the assertion lib)
35
+ };
36
+ let describesThrownCount = 0;
37
+ for (const testFile in runTestResults) {
38
+ const runTestResult = runTestResults[testFile];
39
+ if (!runTestResult)
40
+ continue;
41
+ testsResultsSummary.total += +(runTestResult.success !== null);
42
+ testsResultsSummary.passes += +(runTestResult.success ?? false);
43
+ testsResultsSummary.invalid += +(runTestResult.success === null);
44
+ testsResultsSummary.describesTotal += runTestResult.describeResultsSummary.total;
45
+ testsResultsSummary.describesPasses += runTestResult.describeResultsSummary.passes;
46
+ testsResultsSummary.describesInvalid += runTestResult.describeResultsSummary.invalid;
47
+ testsResultsSummary.itsTotal += runTestResult.describeResultsSummary.itsTotal;
48
+ testsResultsSummary.itsPasses += runTestResult.describeResultsSummary.itsPasses;
49
+ describesThrownCount += runTestResult.describeResults
50
+ .filter(describeResult => describeResult.error !== undefined)
51
+ .length;
52
+ }
53
+ const failedToLoadCount = count(erroringTests);
54
+ testsResultsSummary.total += failedToLoadCount;
55
+ if ((filters.describe !== undefined || filters.it !== undefined)
56
+ && testsResultsSummary.itsTotal === 0
57
+ && failedToLoadCount === 0
58
+ && describesThrownCount === 0) {
59
+ out(chalk.orange('No tests matched the describe/test filters.'));
60
+ const durationMs = new Date().getTime() - runStartTime;
61
+ writeStatusFile(config, statusCodes.couldNotRun, 'no tests matched the describe/test filters', [], durationMs);
62
+ agentDone(config, runNumber, statusCodes.couldNotRun, 'no tests matched the describe/test filters', testsResultsSummary, durationMs, state.failedTestFiles.size);
63
+ return null;
64
+ }
65
+ const allPassed = (testsResultsSummary.passes === testsResultsSummary.total
66
+ && testsResultsSummary.describesPasses === testsResultsSummary.describesTotal
67
+ && testsResultsSummary.itsPasses === testsResultsSummary.itsTotal);
68
+ const failedTestsCount = testsResultsSummary.itsTotal - testsResultsSummary.itsPasses;
69
+ // a file that would not load, or a describe that threw, has no tests in itsTotal -
70
+ // each counts as one unit on both sides
71
+ const failuresN = failedTestsCount + describesThrownCount + failedToLoadCount;
72
+ const unitsN = testsResultsSummary.itsTotal + describesThrownCount + failedToLoadCount;
73
+ // the originals may have scrolled away on a long run, but past a point repeating
74
+ // them buries the tallies - and when everything failed, they are the whole output already
75
+ const showFailuresSection = config.restateFailures && failuresN > 0 && failuresN < unitsN
76
+ && (failuresN <= 10 || failuresN <= 1.7 * unitsN ** 0.58);
77
+ // the rule is separation enough, without the tallies' wider gap
78
+ out((config.compact || showFailuresSection) ? '' : '\n');
79
+ if (allPassed) {
80
+ out(chalk.mediumgreen(`${figures.tick}`));
81
+ }
82
+ else {
83
+ //showFailures(out, Object.values(runTestResults), erroringTests)
84
+ if (showFailuresSection) {
85
+ const hr = '='.repeat((process.stdout.columns ?? 41) - 1);
86
+ out(hr);
87
+ out('Failures:');
88
+ out(hr);
89
+ for (const test of Object.values(erroringTests))
90
+ showTestLoadingError(config, test, out);
91
+ for (const testResult of Object.values(runTestResults)) {
92
+ if (testResult.success !== false)
93
+ continue;
94
+ showTestFileResult(config, testResult, out, { failuresOnly: true });
95
+ }
96
+ out(config.compact ? '' : '\n');
97
+ }
98
+ out(chalk.mediumred(`${figures.cross}`));
99
+ }
100
+ // number of tests successful
101
+ const testsText = `Tests: ${testsResultsSummary.itsPasses}/${testsResultsSummary.itsTotal}`;
102
+ if (testsResultsSummary.itsPasses === testsResultsSummary.itsTotal) {
103
+ if (testsResultsSummary.itsTotal === 0) {
104
+ out(chalk.grey(`${testsText}`));
105
+ }
106
+ else {
107
+ out(chalk.mediumgreen(`${testsText}`));
108
+ }
109
+ }
110
+ else {
111
+ out(chalk.mediumred(`${testsText}`));
112
+ }
113
+ // number of items successful
114
+ const describesText = `Items: ${testsResultsSummary.describesPasses}/${testsResultsSummary.describesTotal}`;
115
+ const invalidDescribesPlain = (testsResultsSummary.describesInvalid >= 1)
116
+ ? (testsResultsSummary.describesInvalid === 1)
117
+ ? '(+1 describe without tests)'
118
+ : `(+${testsResultsSummary.describesInvalid} describes without tests)`
119
+ : '';
120
+ const describesThrownPlain = (describesThrownCount >= 1)
121
+ ? (describesThrownCount === 1)
122
+ ? '(1 describe errored)'
123
+ : `(${describesThrownCount} describes errored)`
124
+ : '';
125
+ const describesDetailsText = [
126
+ chalk.mediumred(describesThrownPlain), chalk.grey(invalidDescribesPlain)
127
+ ]
128
+ .filter(text => text !== '')
129
+ .join(' ');
130
+ const describesDetailsSuffix = describesDetailsText === '' ? '' : ` ${describesDetailsText}`;
131
+ if (testsResultsSummary.describesPasses === testsResultsSummary.describesTotal) {
132
+ if (testsResultsSummary.describesTotal === 0) {
133
+ out(chalk.grey(`${describesText}`) + describesDetailsSuffix);
134
+ }
135
+ else {
136
+ out(chalk.mediumgreen(`${describesText}`) + describesDetailsSuffix);
137
+ }
138
+ }
139
+ else {
140
+ out(chalk.mediumred(`${describesText}`) + describesDetailsSuffix);
141
+ }
142
+ // number of test files successful
143
+ const testFilesText = `Test Files: ${testsResultsSummary.passes}/${testsResultsSummary.total}`;
144
+ const invalidTestFilesPlain = (testsResultsSummary.invalid >= 1)
145
+ ? (testsResultsSummary.invalid === 1)
146
+ ? '(+1 file without tests)'
147
+ : `(+${testsResultsSummary.invalid} files without tests)`
148
+ : '';
149
+ const failedToLoadPlain = (failedToLoadCount >= 1)
150
+ ? (failedToLoadCount === 1)
151
+ ? '(1 file failed to load, or errored)'
152
+ : `(${failedToLoadCount} files failed to load, or errored)`
153
+ : '';
154
+ const testFilesDetailsText = [
155
+ chalk.mediumred(failedToLoadPlain), chalk.grey(invalidTestFilesPlain)
156
+ ]
157
+ .filter(text => text !== '')
158
+ .join(' ');
159
+ const testFilesDetailsSuffix = testFilesDetailsText === '' ? '' : ` ${testFilesDetailsText}`;
160
+ if (testsResultsSummary.passes === testsResultsSummary.total) {
161
+ if (testsResultsSummary.describesTotal === 0) {
162
+ out(chalk.grey(`${testFilesText}`) + testFilesDetailsSuffix);
163
+ }
164
+ else {
165
+ out(chalk.mediumgreen(`${testFilesText}`) + testFilesDetailsSuffix);
166
+ }
167
+ }
168
+ else {
169
+ out(chalk.mediumred(`${testFilesText}`) + testFilesDetailsSuffix);
170
+ }
171
+ // the tallies only cover what ran, so say the run was cut short - otherwise
172
+ // "Tests: 0/1" reads as a one test suite
173
+ const stoppedPlain = (stop.stopped)
174
+ ? 'stopped at the first failure (failFast)'
175
+ : '';
176
+ if (stoppedPlain !== '')
177
+ out(chalk.orange(stoppedPlain));
178
+ const summaryLines = [
179
+ testsText,
180
+ joinPlain(describesText, describesThrownPlain, invalidDescribesPlain),
181
+ joinPlain(testFilesText, failedToLoadPlain, invalidTestFilesPlain),
182
+ ...(stoppedPlain === '') ? [] : [stoppedPlain]
183
+ ];
184
+ const durationMs = new Date().getTime() - runStartTime;
185
+ if (allPassed) {
186
+ writeStatusFile(config, statusCodes.passed, 'all tests passed', summaryLines, durationMs);
187
+ agentDone(config, runNumber, statusCodes.passed, 'all tests passed', testsResultsSummary, durationMs, state.failedTestFiles.size);
188
+ }
189
+ else {
190
+ const abortedFiles = Object.keys(erroringTests);
191
+ // a file that would not load, or a describe that threw, means the run died
192
+ // partway - a different problem from tests that ran and failed
193
+ const aborted = abortedFiles.length > 0 || describesThrownCount > 0;
194
+ const description = ([
195
+ plural(abortedFiles.length, 'test file', 'failed to load or errored'),
196
+ plural(describesThrownCount, 'describe', 'errored'),
197
+ plural(failedTestsCount, 'test', 'failed')
198
+ ].filter(part => part !== '').join(', ') || 'test run failed')
199
+ + ((stop.stopped) ? ', stopped at the first failure' : '');
200
+ const code = (aborted) ? statusCodes.aborted : statusCodes.failed;
201
+ const failures = failureEntries(Object.values(runTestResults), erroringTests, config.agentLineLengthLimit);
202
+ writeStatusFile(config, code, description, [...summaryLines, ...failureLines(Object.values(runTestResults), erroringTests)], durationMs);
203
+ // failures first, so the done line is a complete end of run marker
204
+ for (const failure of failures)
205
+ agentFailure(config, runNumber, failure);
206
+ agentDone(config, runNumber, code, description, testsResultsSummary, durationMs, state.failedTestFiles.size);
207
+ }
208
+ // full success?
209
+ // true/false gets returned to the caller of runTests()
210
+ return allPassed;
211
+ });
212
+ }
213
+ //# sourceMappingURL=showTestResultsSummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"showTestResultsSummary.js","sourceRoot":"","sources":["../../../src/cli/lib/showTestResultsSummary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAS1C,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,kDAAkD;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAG/C,8DAA8D;AAC9D,SAAS,SAAS,CAAC,GAAG,KAAe;IACjC,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAA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A;IACpB,CAAC,CAAC,CAAA;AACN,CAAC","sourcesContent":["\r\nimport { count } from 'sxy-lib/objects.js'\r\n\r\nimport type { FinalConfig, OutFn } from '../../types.js'\r\nimport type { TestExecutionFilters } from '../cliTypes.js'\r\nimport type { TestFile } from './loadTestFile.js'\r\nimport type { ReRunManageState } from './makeWatchRunState.js'\r\nimport type { TestResult } from './runTest.js'\r\nimport type { TestsResultsSummary } from './runTests.js'\r\nimport type { StopSignal } from './stopSignal.js'\r\nimport chalk from '../../packages/chalk.js'\r\nimport figures from '../../packages/figures.js'\r\nimport { agentDone, agentFailure } from './agentReport.js'\r\nimport { failureEntries } from './failureEntries.js'\r\nimport { failureLines } from './failureLines.js'\r\n//import { showFailures } from './showFailures.js'\r\nimport { showTestFileResult } from './showTestFileResult.js'\r\nimport { showTestLoadingError } from './showTestLoadingError.js'\r\nimport { writeStatusFile, statusCodes } from './statusFile.js'\r\nimport { out as mainOut } from '../../output.js'\r\nimport { timeProfile } from './timeProfiler.js'\r\n\r\n\r\n// the summary lines, minus the colouring, for the status file\r\nfunction joinPlain(...parts: string[]): string {\r\n return parts.filter(part => part !== '').join(' ')\r\n}\r\n\r\nfunction plural(count: number, noun: string, verb: string): string {\r\n if (count < 1) return ''\r\n return `${count} ${noun}${count === 1 ? '' : 's'} ${verb}`\r\n}\r\n\r\nexport function showTestResultsSummary(\r\n runTestResults: Record<string, TestResult>,\r\n erroringTests: Record<string, TestFile>,\r\n runStartTime: number,\r\n config: FinalConfig,\r\n runNumber: number,\r\n state: ReRunManageState,\r\n stop: StopSignal,\r\n filters: TestExecutionFilters,\r\n customOut?: OutFn,\r\n) {\r\n return timeProfile('show test run result summary', () => {\r\n \r\n const out = customOut ?? mainOut\r\n\r\n const testsResultsSummary: TestsResultsSummary = {\r\n total: 0,\r\n passes: 0,\r\n invalid: 0,\r\n describesTotal: 0,\r\n describesPasses: 0,\r\n describesInvalid: 0,\r\n itsTotal: 0,\r\n itsPasses: 0\r\n // itsInvalid: 0 // we don't check whether tests run any asserts (we don't control the assertion lib)\r\n }\r\n let describesThrownCount = 0\r\n\r\n for (const testFile in runTestResults) {\r\n const runTestResult = runTestResults[testFile]\r\n if (!runTestResult) continue\r\n\r\n testsResultsSummary.total += +(runTestResult.success !== null)\r\n testsResultsSummary.passes += +(runTestResult.success ?? false)\r\n testsResultsSummary.invalid += +(runTestResult.success === null)\r\n testsResultsSummary.describesTotal += runTestResult.describeResultsSummary.total\r\n testsResultsSummary.describesPasses += runTestResult.describeResultsSummary.passes\r\n testsResultsSummary.describesInvalid += runTestResult.describeResultsSummary.invalid\r\n testsResultsSummary.itsTotal += runTestResult.describeResultsSummary.itsTotal\r\n testsResultsSummary.itsPasses += runTestResult.describeResultsSummary.itsPasses\r\n describesThrownCount += runTestResult.describeResults\r\n .filter(describeResult => describeResult.error !== undefined)\r\n .length\r\n }\r\n\r\n const failedToLoadCount = count(erroringTests)\r\n testsResultsSummary.total += failedToLoadCount\r\n\r\n if (\r\n (filters.describe !== undefined || filters.it !== undefined)\r\n && testsResultsSummary.itsTotal === 0\r\n && failedToLoadCount === 0\r\n && describesThrownCount === 0\r\n ) {\r\n out(chalk.orange('No tests matched the describe/test filters.'))\r\n const durationMs = new Date().getTime() - runStartTime\r\n writeStatusFile(\r\n config,\r\n statusCodes.couldNotRun,\r\n 'no tests matched the describe/test filters',\r\n [],\r\n durationMs\r\n )\r\n agentDone(\r\n config, runNumber, statusCodes.couldNotRun,\r\n 'no tests matched the describe/test filters', testsResultsSummary, durationMs,\r\n state.failedTestFiles.size\r\n )\r\n return null\r\n }\r\n\r\n const allPassed = (\r\n testsResultsSummary.passes === testsResultsSummary.total\r\n && testsResultsSummary.describesPasses === testsResultsSummary.describesTotal\r\n && testsResultsSummary.itsPasses === testsResultsSummary.itsTotal\r\n )\r\n\r\n const failedTestsCount = testsResultsSummary.itsTotal - testsResultsSummary.itsPasses\r\n\r\n // a file that would not load, or a describe that threw, has no tests in itsTotal -\r\n // each counts as one unit on both sides\r\n const failuresN = failedTestsCount + describesThrownCount + failedToLoadCount\r\n const unitsN = testsResultsSummary.itsTotal + describesThrownCount + failedToLoadCount\r\n\r\n // the originals may have scrolled away on a long run, but past a point repeating\r\n // them buries the tallies - and when everything failed, they are the whole output already\r\n const showFailuresSection = config.restateFailures && failuresN > 0 && failuresN < unitsN\r\n && (failuresN <= 10 || failuresN <= 1.7 * unitsN ** 0.58)\r\n\r\n // the rule is separation enough, without the tallies' wider gap\r\n out((config.compact || showFailuresSection) ? '' : '\\n')\r\n\r\n if (allPassed) {\r\n out(chalk.mediumgreen(`${figures.tick}`))\r\n } else {\r\n //showFailures(out, Object.values(runTestResults), erroringTests)\r\n if (showFailuresSection) {\r\n \r\n const hr = '='.repeat((process.stdout.columns ?? 41) - 1)\r\n out(hr)\r\n out('Failures:')\r\n out(hr)\r\n\r\n for (const test of Object.values(erroringTests)) showTestLoadingError(config, test, out)\r\n for (const testResult of Object.values(runTestResults)) {\r\n if (testResult.success !== false) continue\r\n showTestFileResult(config, testResult, out, { failuresOnly: true })\r\n }\r\n out(config.compact ? '' : '\\n')\r\n }\r\n out(chalk.mediumred(`${figures.cross}`))\r\n }\r\n\r\n // number of tests successful\r\n const testsText = `Tests: ${testsResultsSummary.itsPasses}/${testsResultsSummary.itsTotal}`\r\n if (testsResultsSummary.itsPasses === testsResultsSummary.itsTotal) {\r\n if (testsResultsSummary.itsTotal === 0) {\r\n out(chalk.grey(`${testsText}`))\r\n } else {\r\n out(chalk.mediumgreen(`${testsText}`))\r\n }\r\n } else {\r\n out(chalk.mediumred(`${testsText}`))\r\n }\r\n\r\n // number of items successful\r\n const describesText = `Items: ${testsResultsSummary.describesPasses}/${testsResultsSummary.describesTotal}`\r\n const invalidDescribesPlain = (testsResultsSummary.describesInvalid >= 1)\r\n ? (testsResultsSummary.describesInvalid === 1)\r\n ? '(+1 describe without tests)'\r\n : `(+${testsResultsSummary.describesInvalid} describes without tests)`\r\n : ''\r\n const describesThrownPlain = (describesThrownCount >= 1)\r\n ? (describesThrownCount === 1)\r\n ? '(1 describe errored)'\r\n : `(${describesThrownCount} describes errored)`\r\n : ''\r\n const describesDetailsText = [\r\n chalk.mediumred(describesThrownPlain), chalk.grey(invalidDescribesPlain)\r\n ]\r\n .filter(text => text !== '')\r\n .join(' ')\r\n const describesDetailsSuffix = describesDetailsText === '' ? '' : ` ${describesDetailsText}`\r\n if (testsResultsSummary.describesPasses === testsResultsSummary.describesTotal) {\r\n if (testsResultsSummary.describesTotal === 0) {\r\n out(chalk.grey(`${describesText}`) + describesDetailsSuffix)\r\n } else {\r\n out(chalk.mediumgreen(`${describesText}`) + describesDetailsSuffix)\r\n }\r\n } else {\r\n out(chalk.mediumred(`${describesText}`) + describesDetailsSuffix)\r\n }\r\n\r\n // number of test files successful\r\n const testFilesText = `Test Files: ${testsResultsSummary.passes}/${testsResultsSummary.total}`\r\n const invalidTestFilesPlain = (testsResultsSummary.invalid >= 1)\r\n ? (testsResultsSummary.invalid === 1)\r\n ? '(+1 file without tests)'\r\n : `(+${testsResultsSummary.invalid} files without tests)`\r\n : ''\r\n const failedToLoadPlain = (failedToLoadCount >= 1)\r\n ? (failedToLoadCount === 1)\r\n ? '(1 file failed to load, or errored)'\r\n : `(${failedToLoadCount} files failed to load, or errored)`\r\n : ''\r\n const testFilesDetailsText = [\r\n chalk.mediumred(failedToLoadPlain), chalk.grey(invalidTestFilesPlain)\r\n ]\r\n .filter(text => text !== '')\r\n .join(' ')\r\n const testFilesDetailsSuffix = testFilesDetailsText === '' ? '' : ` ${testFilesDetailsText}`\r\n if (testsResultsSummary.passes === testsResultsSummary.total) {\r\n if (testsResultsSummary.describesTotal === 0) {\r\n out(chalk.grey(`${testFilesText}`) + testFilesDetailsSuffix)\r\n } else {\r\n out(chalk.mediumgreen(`${testFilesText}`) + testFilesDetailsSuffix)\r\n }\r\n } else {\r\n out(chalk.mediumred(`${testFilesText}`) + testFilesDetailsSuffix)\r\n }\r\n\r\n // the tallies only cover what ran, so say the run was cut short - otherwise\r\n // \"Tests: 0/1\" reads as a one test suite\r\n const stoppedPlain = (stop.stopped)\r\n ? 'stopped at the first failure (failFast)'\r\n : ''\r\n if (stoppedPlain !== '') out(chalk.orange(stoppedPlain))\r\n\r\n const summaryLines = [\r\n testsText,\r\n joinPlain(describesText, describesThrownPlain, invalidDescribesPlain),\r\n joinPlain(testFilesText, failedToLoadPlain, invalidTestFilesPlain),\r\n ...(stoppedPlain === '') ? [] : [stoppedPlain]\r\n ]\r\n\r\n const durationMs = new Date().getTime() - runStartTime\r\n\r\n if (allPassed) {\r\n writeStatusFile(\r\n config, statusCodes.passed, 'all tests passed', summaryLines, durationMs\r\n )\r\n agentDone(\r\n config, runNumber, statusCodes.passed, 'all tests passed',\r\n testsResultsSummary, durationMs, state.failedTestFiles.size\r\n )\r\n } else {\r\n const abortedFiles = Object.keys(erroringTests)\r\n\r\n // a file that would not load, or a describe that threw, means the run died\r\n // partway - a different problem from tests that ran and failed\r\n const aborted = abortedFiles.length > 0 || describesThrownCount > 0\r\n\r\n const description = ([\r\n plural(abortedFiles.length, 'test file', 'failed to load or errored'),\r\n plural(describesThrownCount, 'describe', 'errored'),\r\n plural(failedTestsCount, 'test', 'failed')\r\n ].filter(part => part !== '').join(', ') || 'test run failed')\r\n + ((stop.stopped) ? ', stopped at the first failure' : '')\r\n\r\n const code = (aborted) ? statusCodes.aborted : statusCodes.failed\r\n const failures = failureEntries(\r\n Object.values(runTestResults), erroringTests, config.agentLineLengthLimit\r\n )\r\n\r\n writeStatusFile(\r\n config,\r\n code,\r\n description,\r\n [...summaryLines, ...failureLines(Object.values(runTestResults), erroringTests)],\r\n durationMs\r\n )\r\n\r\n // failures first, so the done line is a complete end of run marker\r\n for (const failure of failures) agentFailure(config, runNumber, failure)\r\n agentDone(\r\n config, runNumber, code, description, testsResultsSummary, durationMs,\r\n state.failedTestFiles.size\r\n )\r\n }\r\n\r\n // full success?\r\n // true/false gets returned to the caller of runTests()\r\n return allPassed\r\n })\r\n}\r\n"]}
@@ -0,0 +1,3 @@
1
+ declare const timeProfile: <T>(name: string, task: () => T) => T, timeProfileAsync: <T>(name: string, task: () => Promise<T>) => Promise<T>;
2
+ export { timeProfile, timeProfileAsync };
3
+ //# sourceMappingURL=timeProfiler.d.ts.map
@@ -2,4 +2,4 @@ import { createTimeProfiler } from '../../packages/timeProfiler.js';
2
2
  import { showTimeProfiling } from '../../config.js';
3
3
  const { timeProfile, timeProfileAsync } = createTimeProfiler(showTimeProfiling);
4
4
  export { timeProfile, timeProfileAsync };
5
- //# sourceMappingURL=timeProfier.js.map
5
+ //# sourceMappingURL=timeProfiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeProfiler.js","sourceRoot":"","sources":["../../../src/cli/lib/timeProfiler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAGnD,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAE/E,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAA","sourcesContent":["\nimport { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\n\n\nconst { timeProfile, timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport { timeProfile, timeProfileAsync }\n"]}
@@ -8,9 +8,16 @@ export function validateConfig(config, customOut) {
8
8
  if (typeof config.compact !== 'boolean') {
9
9
  doError('Config error, config.compact should be a boolean');
10
10
  }
11
+ if (typeof config.restateFailures !== 'boolean') {
12
+ doError('Config error, config.restateFailures should be a boolean');
13
+ }
11
14
  if (typeof config.agent !== 'boolean') {
12
15
  doError('Config error, config.agent should be a boolean');
13
16
  }
17
+ const limit = config.agentLineLengthLimit;
18
+ if (typeof limit !== 'number' || !(limit > 0) || !(Number.isInteger(limit) || limit === Infinity)) {
19
+ doError('Config error, config.agentLineLengthLimit should be a positive whole number or Infinity');
20
+ }
14
21
  if (config.execution === undefined) {
15
22
  doError('Config error, config.execution is not defined');
16
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validateConfig.js","sourceRoot":"","sources":["../../../src/cli/lib/validateConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAGhD,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,SAAiB;IACjE,MAAM,GAAG,GAAG,SAAS,IAAI,OAAO,CAAA;IAEhC,SAAS,OAAO,CAAC,OAAe;QAC5B,GAAG,CAAC,OAAO,CAAC,CAAA;QACZ,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,CAAC,kDAAkD,CAAC,CAAA;IAC/D,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,CAAC,gDAAgD,CAAC,CAAA;IAC7D,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,+CAA+C,CAAC,CAAA;IAC5D,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QACnF,OAAO,CAAC,+EAA+E,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;QAC3F,OAAO,CAAC,mFAAmF,CAAC,CAAA;IAChG,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QACnF,OAAO,CAAC,+EAA+E,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,CAAC,qEAAqE,CAAC,CAAA;IAClF,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAA;IAC1C,IAAI,UAAU,KAAK,KAAK,IAAI,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,EAAE,CAAC,EAAE,CAAC;QAChF,OAAO,CAAC,sEAAsE,CAAC,CAAA;IACnF,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,CAAC,qEAAqE,CAAC,CAAA;IAClF,CAAC;AACL,CAAC","sourcesContent":["\nimport type { FinalConfig, OutFn } from '../../types.js'\nimport { out as mainOut } from '../../output.js'\n\n\nexport function validateConfig(config: FinalConfig, customOut?: OutFn): void {\n const out = customOut ?? mainOut\n\n function doError(message: string): never {\n out(message)\n throw new Error(message)\n }\n\n if (typeof config.compact !== 'boolean') {\n doError('Config error, config.compact should be a boolean')\n }\n\n if (typeof config.agent !== 'boolean') {\n doError('Config error, config.agent should be a boolean')\n }\n\n if (config.execution === undefined) {\n doError('Config error, config.execution is not defined')\n }\n\n if (config.execution.files !== 'parallel' && config.execution.files !== 'sequential') {\n doError('Config error, config.execution.files should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.describes !== 'parallel' && config.execution.describes !== 'sequential') {\n doError('Config error, config.execution.describes should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.tests !== 'parallel' && config.execution.tests !== 'sequential') {\n doError('Config error, config.execution.tests should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (typeof config.watch.ttyActionsOnKeypress !== 'boolean') {\n doError('Config error, config.watch.ttyActionsOnKeypress should be a boolean')\n }\n\n const statusFile = config.watch.statusFile\n if (statusFile !== false && (typeof statusFile !== 'string' || statusFile === '')) {\n doError('Config error, config.watch.statusFile should be false or a file path')\n }\n\n if (typeof config.watch.dependencyEvaluation !== 'boolean') {\n doError('Config error, config.watch.dependencyEvaluation should be a boolean')\n }\n}\n"]}
1
+ {"version":3,"file":"validateConfig.js","sourceRoot":"","sources":["../../../src/cli/lib/validateConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAGhD,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,SAAiB;IACjE,MAAM,GAAG,GAAG,SAAS,IAAI,OAAO,CAAA;IAEhC,SAAS,OAAO,CAAC,OAAe;QAC5B,GAAG,CAAC,OAAO,CAAC,CAAA;QACZ,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,CAAC,kDAAkD,CAAC,CAAA;IAC/D,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QAC9C,OAAO,CAAC,0DAA0D,CAAC,CAAA;IACvE,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,CAAC,gDAAgD,CAAC,CAAA;IAC7D,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,oBAAoB,CAAA;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC;QAChG,OAAO,CAAC,yFAAyF,CAAC,CAAA;IACtG,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,+CAA+C,CAAC,CAAA;IAC5D,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QACnF,OAAO,CAAC,+EAA+E,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;QAC3F,OAAO,CAAC,mFAAmF,CAAC,CAAA;IAChG,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QACnF,OAAO,CAAC,+EAA+E,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,CAAC,qEAAqE,CAAC,CAAA;IAClF,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAA;IAC1C,IAAI,UAAU,KAAK,KAAK,IAAI,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,EAAE,CAAC,EAAE,CAAC;QAChF,OAAO,CAAC,sEAAsE,CAAC,CAAA;IACnF,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,CAAC,qEAAqE,CAAC,CAAA;IAClF,CAAC;AACL,CAAC","sourcesContent":["\nimport type { FinalConfig, OutFn } from '../../types.js'\nimport { out as mainOut } from '../../output.js'\n\n\nexport function validateConfig(config: FinalConfig, customOut?: OutFn): void {\n const out = customOut ?? mainOut\n\n function doError(message: string): never {\n out(message)\n throw new Error(message)\n }\n\n if (typeof config.compact !== 'boolean') {\n doError('Config error, config.compact should be a boolean')\n }\n\n if (typeof config.restateFailures !== 'boolean') {\n doError('Config error, config.restateFailures should be a boolean')\n }\n\n if (typeof config.agent !== 'boolean') {\n doError('Config error, config.agent should be a boolean')\n }\n\n const limit = config.agentLineLengthLimit\n if (typeof limit !== 'number' || !(limit > 0) || !(Number.isInteger(limit) || limit === Infinity)) {\n doError('Config error, config.agentLineLengthLimit should be a positive whole number or Infinity')\n }\n\n if (config.execution === undefined) {\n doError('Config error, config.execution is not defined')\n }\n\n if (config.execution.files !== 'parallel' && config.execution.files !== 'sequential') {\n doError('Config error, config.execution.files should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.describes !== 'parallel' && config.execution.describes !== 'sequential') {\n doError('Config error, config.execution.describes should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.tests !== 'parallel' && config.execution.tests !== 'sequential') {\n doError('Config error, config.execution.tests should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (typeof config.watch.ttyActionsOnKeypress !== 'boolean') {\n doError('Config error, config.watch.ttyActionsOnKeypress should be a boolean')\n }\n\n const statusFile = config.watch.statusFile\n if (statusFile !== false && (typeof statusFile !== 'string' || statusFile === '')) {\n doError('Config error, config.watch.statusFile should be false or a file path')\n }\n\n if (typeof config.watch.dependencyEvaluation !== 'boolean') {\n doError('Config error, config.watch.dependencyEvaluation should be a boolean')\n }\n}\n"]}
package/dist/cli/once.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import chalk from '../packages/chalk.js';
2
2
  import { packageName, configFileNames } from '../config.js';
3
3
  import { out, log } from '../output.js';
4
- import { setEnv } from './lib/setEnv.js';
4
+ import { setEnv, setAgentEnv } from './lib/setEnv.js';
5
5
  import { findingTestsMessage } from './lib/findingTestsMessage.js';
6
6
  import { foundTestsMessage } from './lib/foundTestsMessage.js';
7
7
  //import { isTest } from './lib/isTest.js'
@@ -93,6 +93,7 @@ export async function once() {
93
93
  else if (config.agent)
94
94
  agentInit(true); // set by the config: announced once it has loaded
95
95
  agentMode = config.agent;
96
+ setAgentEnv(agentMode);
96
97
  agentSetRunReason('once');
97
98
  const runsOut = (agentMode) ? agentSilentOut : undefined;
98
99
  agentOut(chalk.brightblue `[${packageName}]...`);
@@ -1 +1 @@
1
- {"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/cli/once.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,0CAA0C;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,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;YACd,MAAM,EAAE,IAAI;SACf;QACD,MAAM,EAAE;YACJ,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI;SACf;QACD,WAAW,EAAE;YACT,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,iBAAiB,EAAE;YACf,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IA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QAAQ,GAAG,CAAC,WAAW,KAAK,IAAI,CAAC;QACnC,CAAC,CAAC,SAAS,CAAC,eAAe;QAC3B,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAA;IAE7D,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAA,KAAK,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;IAEpD,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 type { OutFn } from '../types.js'\nimport type { AllowedArguments } from './cliTypes.js'\nimport type { Concurrency } from './lib/runTests.js'\nimport chalk from '../packages/chalk.js'\nimport { packageName, configFileNames } from '../config.js'\nimport { out, log } from '../output.js'\nimport { setEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\n//import { isTest } from './lib/isTest.js'\nimport { exitCodes } from './lib/exitCodes.js'\nimport { alwaysCacheBust } from './lib/alwaysCacheBust.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 isGlob: true\n },\n filter: {\n flag: 'f',\n hasValue: true,\n isGlob: 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 'compact': {\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. Under the flag, announced before the config loads, as in watch mode.\n const agentFlag = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentSetRunReason, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentFlag)\n // the config can still turn agent mode on, so this is settled once it has loaded\n let agentMode = agentFlag\n const agentOut: OutFn = (...texts) => { if (!agentMode) out(...texts) }\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 // the flag is the only source: assigned rather than or'd, so a config file cannot\n // silently truncate every run\n config.failFast = clArguments['fail-fast'] === true\n if (agentFlag) config.agent = true\n else if (config.agent) agentInit(true) // set by the config: announced once it has loaded\n agentMode = config.agent\n agentSetRunReason('once')\n const runsOut = (agentMode) ? agentSilentOut : undefined\n agentOut(chalk.brightblue`[${packageName}]...`)\n if (clArguments.compact === true) config.compact = true\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, agentOut)\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(exitCodes.noTestFiles)\n }\n\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n const concurrency: Concurrency = { limit: -1 }\n\n process.setSourceMapsEnabled(true) // enable source mapping\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 concurrency,\n (alwaysCacheBust) ? 'refresh' : 'cached',\n runsOut,\n {\n it: filterIt,\n describe: filterDescribe\n }\n )\n // a distinct code from noTestFiles, so callers can tell \"no test file matched the\n // pattern\" from \"the files matched but the filters selected nothing in them\"\n const exitCode = (testsResult === null)\n ? exitCodes.noMatchingTests\n : (testsResult) ? exitCodes.passed : exitCodes.testErrors\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"]}
1
+ {"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/cli/once.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,0CAA0C;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,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;YACd,MAAM,EAAE,IAAI;SACf;QACD,MAAM,EAAE;YACJ,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI;SACf;QACD,WAAW,EAAE;YACT,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SAC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AE,EAAE,QAAQ;QACZ,QAAQ,EAAE,cAAc;KAC3B,CACJ,CAAA;IACD,kFAAkF;IAClF,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,CAAC,WAAW,KAAK,IAAI,CAAC;QACnC,CAAC,CAAC,SAAS,CAAC,eAAe;QAC3B,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAA;IAE7D,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAA,KAAK,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;IAEpD,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 type { OutFn } from '../types.js'\nimport type { AllowedArguments } from './cliTypes.js'\nimport type { Concurrency } from './lib/runTests.js'\nimport chalk from '../packages/chalk.js'\nimport { packageName, configFileNames } from '../config.js'\nimport { out, log } from '../output.js'\nimport { setEnv, setAgentEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\n//import { isTest } from './lib/isTest.js'\nimport { exitCodes } from './lib/exitCodes.js'\nimport { alwaysCacheBust } from './lib/alwaysCacheBust.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 isGlob: true\n },\n filter: {\n flag: 'f',\n hasValue: true,\n isGlob: 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 'compact': {\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. Under the flag, announced before the config loads, as in watch mode.\n const agentFlag = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentSetRunReason, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentFlag)\n // the config can still turn agent mode on, so this is settled once it has loaded\n let agentMode = agentFlag\n const agentOut: OutFn = (...texts) => { if (!agentMode) out(...texts) }\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 // the flag is the only source: assigned rather than or'd, so a config file cannot\n // silently truncate every run\n config.failFast = clArguments['fail-fast'] === true\n if (agentFlag) config.agent = true\n else if (config.agent) agentInit(true) // set by the config: announced once it has loaded\n agentMode = config.agent\n setAgentEnv(agentMode)\n agentSetRunReason('once')\n const runsOut = (agentMode) ? agentSilentOut : undefined\n agentOut(chalk.brightblue`[${packageName}]...`)\n if (clArguments.compact === true) config.compact = true\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, agentOut)\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(exitCodes.noTestFiles)\n }\n\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n const concurrency: Concurrency = { limit: -1 }\n\n process.setSourceMapsEnabled(true) // enable source mapping\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 concurrency,\n (alwaysCacheBust) ? 'refresh' : 'cached',\n runsOut,\n {\n it: filterIt,\n describe: filterDescribe\n }\n )\n // a distinct code from noTestFiles, so callers can tell \"no test file matched the\n // pattern\" from \"the files matched but the filters selected nothing in them\"\n const exitCode = (testsResult === null)\n ? exitCodes.noMatchingTests\n : (testsResult) ? exitCodes.passed : exitCodes.testErrors\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"]}
@@ -1,4 +1,4 @@
1
1
  export type StopFn = () => void;
2
2
  export declare function watch(): Promise<void>;
3
- export declare function doWatch(): Promise<StopFn>;
3
+ export declare function doWatch(input?: NodeJS.ReadStream): Promise<StopFn>;
4
4
  //# sourceMappingURL=watch.d.ts.map
package/dist/cli/watch.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import chalk from '../packages/chalk.js';
2
2
  import { packageName } from '../config.js';
3
3
  import { out, debug } from '../output.js';
4
- import { setEnv } from './lib/setEnv.js';
4
+ import { setEnv, setAgentEnv } from './lib/setEnv.js';
5
5
  import { findingTestsMessage } from './lib/findingTestsMessage.js';
6
6
  import { foundTestsMessage } from './lib/foundTestsMessage.js';
7
7
  //import { isTest } from './lib/isTest.js'
@@ -12,7 +12,8 @@ export async function watch() {
12
12
  await doWatch();
13
13
  await new Promise(() => { });
14
14
  }
15
- export async function doWatch() {
15
+ // input is injectable so tests never read the terminal their runner is also reading
16
+ export async function doWatch(input = process.stdin) {
16
17
  const startTime = new Date().getTime();
17
18
  const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js');
18
19
  const allowedClArguments = {
@@ -103,6 +104,7 @@ export async function doWatch() {
103
104
  else if (config.agent)
104
105
  agentInit(true); // set by the config: announced once it has loaded
105
106
  agentMode = config.agent;
107
+ setAgentEnv(agentMode);
106
108
  const runsOut = (agentMode) ? agentSilentOut : undefined;
107
109
  agentOut(chalk.brightblue `[${packageName}]...`);
108
110
  if (clArguments.compact === true)
@@ -150,7 +152,7 @@ export async function doWatch() {
150
152
  if (config.watch.dependencyEvaluation) {
151
153
  const { buildDependencyTrees } = await import('./lib/buildDependencyTrees.js');
152
154
  agentOut(chalk.brightblue `finding initial dependency trees...`);
153
- dependencyTrees = await buildDependencyTrees(config, testFiles);
155
+ dependencyTrees = buildDependencyTrees(config, testFiles);
154
156
  }
155
157
  }
156
158
  // live before the first test runs, for two reasons. A change landing during the initial
@@ -196,7 +198,7 @@ export async function doWatch() {
196
198
  const { listenToUser } = await import('./lib/listenToUser.js');
197
199
  const disposeTty = listenToUser(reRunManager, files => () => {
198
200
  return runTests(config, files, reRunManager, concurrency, 'refresh', runsOut, executionFilters);
199
- }, config.watch.ttyActionsOnKeypress, initialTestRun, process.stdin, runsOut);
201
+ }, config.watch.ttyActionsOnKeypress, initialTestRun, input, runsOut);
200
202
  stopFns.push(disposeTty);
201
203
  const dispose = () => {
202
204
  for (const stop of stopFns) {
@@ -1 +1 @@
1
- {"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/cli/watch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,0CAA0C;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAK1D,MAAM,CAAC,KAAK,UAAU,KAAK;IACvB,MAAM,OAAO,EAAE,CAAA;IACf,MAAM,IAAI,OAAO,C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,IAAI,CAAC,CAAA;IAEnE,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAA,aAAa,CAAC,CAAA;IACvC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;IAErC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAA;IAC9D,MAAM,UAAU,GAAG,YAAY,CAC3B,YAAY,EACZ,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE;QACV,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;IACnG,CAAC,EACD,MAAM,CAAC,KAAK,CAAC,oBAAoB,EACjC,cAAc,EACd,OAAO,CAAC,KAAK,EACb,OAAO,CACV,CAAA;IACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAExB,MAAM,OAAO,GAAG,GAAG,EAAE;QACjB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YACzB,IAAI,EAAE,CAAA;QACV,CAAC;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA,CAAC,gBAAgB;IACvC,CAAC,CAAA;IACD,OAAO,OAAO,CAAA;IAGd,iBAAiB;IACjB,wCAAwC;IACxC,OAAO;IACP,mCAAmC;AACvC,CAAC","sourcesContent":["\nimport type { DependencyTrees, OutFn } from '../types.js'\nimport type { AllowedArguments } from './cliTypes.js'\nimport type { Concurrency } from './lib/runTests.js'\nimport chalk from '../packages/chalk.js'\nimport { packageName } from '../config.js'\nimport { out, debug } from '../output.js'\nimport { setEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\n//import { isTest } from './lib/isTest.js'\nimport { makeRunManagerState } from './lib/makeWatchRunState.js'\nimport { makeReRunManager } from './lib/reRunManager.js'\nimport { alwaysCacheBust } from './lib/alwaysCacheBust.js'\n\n\nexport type StopFn = () => void\n\nexport async function watch(): Promise<void> {\n await doWatch()\n await new Promise<void>(() => {})\n}\n\nexport async function doWatch(): Promise<StopFn> {\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 isGlob: true\n },\n 'filter': {\n flag: 'f',\n hasValue: true,\n isGlob: true\n },\n 'filter-it': {\n flag: 'i',\n hasValue: true\n },\n 'filter-describe': {\n flag: 'd',\n hasValue: true\n },\n 'status-file': {\n flag: 's',\n hasValue: true\n },\n 'agent': {\n hasValue: false\n },\n 'compact': {\n hasValue: false\n }\n }\n const clArguments = parseCommandLineArguments(allowedClArguments)\n //debug('clArguments', clArguments)\n\n // agent mode owns stdout, so the banner and every later message below is routed through\n // agentOut - a sink in agent mode. Under the flag, init is announced before the config\n // loads, so a reader sees the process is alive even if startup is slow.\n const agentFlag = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentWatching, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentFlag)\n // the config can still turn agent mode on, so this is settled once it has loaded\n let agentMode = agentFlag\n const agentOut: OutFn = (...texts) => { if (!agentMode) out(...texts) }\n\n setEnv()\n\n const stopFns: StopFn[] = []\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 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 userConfig.testsFilter = filter\n }\n\n if ('status-file' in clArguments) {\n const statusFile = clArguments['status-file']\n if (typeof statusFile !== 'string' || statusFile === '') {\n throw new Error('No file path specified for --status-file or -s argument')\n }\n userConfig.watch = { ...userConfig.watch, statusFile }\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 const executionFilters = { it: filterIt, describe: filterDescribe }\n\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\n const config = applyConfigDefaults(userConfig)\n if (agentFlag) config.agent = true\n else if (config.agent) agentInit(true) // set by the config: announced once it has loaded\n agentMode = config.agent\n const runsOut = (agentMode) ? agentSilentOut : undefined\n agentOut(chalk.brightblue`[${packageName}]...`)\n if (clArguments.compact === true) config.compact = true\n // there is no watch flag for it, and a config file must not enable it here: a truncated\n // run would still report covers=all, and failing files would drop out of `failing`\n config.failFast = false\n\n // not silenced in agent mode - a config error is fatal, so losing the message is worse\n // than breaking the one-line-per-event contract\n const { validateConfig } = await import('./lib/validateConfig.js')\n validateConfig(config)\n\n // no run has finished yet, so the status file starts at -1 rather than stale\n const { resetStatusFile, statusCodes, writeStatusFile } = await import('./lib/statusFile.js')\n resetStatusFile(config)\n\n const { doUserSetup } = await import('./lib/doUserSetup.js')\n await doUserSetup(config, agentOut)\n\n // watch mode never reaches an end of its own, so teardown only gets a chance on the way\n // out. Registered here so it pairs with the setup above and covers the initial run too.\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n const { registerShutdownHandlers } = await import('./lib/shutdown.js')\n \n const unregisterShutdownHandlers = registerShutdownHandlers(config, {\n teardown: doUserTeardown,\n exit: code => process.exit(code)\n })\n stopFns.push(unregisterShutdownHandlers)\n\n agentOut(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n debug(testFiles)\n agentFound(config, testFiles.size)\n\n // global store of the dependencies of tests\n let dependencyTrees: DependencyTrees = {}\n // store failing tests so we can re-run them.\n const failingTests: string[] = []\n \n const concurrency: Concurrency = { limit: -1 }\n\n const reRunManager = makeReRunManager(\n null,\n makeRunManagerState({\n allTestFiles: testFiles,\n lastTestFiles: testFiles\n }),\n runsOut\n )\n\n process.setSourceMapsEnabled(true) // enable source mapping\n\n if (testFiles.size > 0) {\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n // the trees are only consulted to narrow a run, so with evaluation off building them\n // is pure cost - and it is the slowest part of startup on a large suite\n if (config.watch.dependencyEvaluation) {\n const { buildDependencyTrees } = await import('./lib/buildDependencyTrees.js')\n agentOut(chalk.brightblue`finding initial dependency trees...`)\n dependencyTrees = await buildDependencyTrees(config, testFiles)\n }\n }\n\n // live before the first test runs, for two reasons. A change landing during the initial\n // run (a compiler emit, typically) is seen rather than lost. And the watcher starts on a\n // quiet loop: node-watch probes for native recursive support with a 200ms timeout, and a\n // loop busy running tests fails the probe, so it falls back to a sync walk of every\n // directory - which then starved the tests' own timers (a 10ms interval fired once in 45ms)\n const { watchFilesAndRunTests } = await import('./lib/watchFilesAndRunTests.js')\n const stopWatcher = await watchFilesAndRunTests(\n config,\n //testFiles,\n dependencyTrees,\n failingTests, // CHECK this should also be in state\n reRunManager,\n //watchRunState,\n runsOut,\n executionFilters\n )\n stopFns.push(stopWatcher)\n\n const { runTests } = await import('./lib/runTests.js')\n let initialTestRun: Promise<boolean | null> | null = null\n if (testFiles.size > 0) {\n if (config.watch.runAllOnStartup) {\n agentOut(chalk.brightblue`running initial tests...`)\n initialTestRun = runTests(\n config, testFiles,\n reRunManager,\n concurrency,\n (alwaysCacheBust) ? 'refresh' : 'cached',\n runsOut, executionFilters\n ).then(testsResult => {\n const time = new Date().getTime() - startTime\n //await new Promise((resolve) => setTimeout(resolve, 100))\n agentOut(chalk.grey`\\n${time.toLocaleString()}ms`)\n return testsResult\n })\n reRunManager.state.currentRun = initialTestRun\n }\n } else {\n agentOut(chalk.orange`no test files found`)\n writeStatusFile(config, statusCodes.couldNotRun, 'no test files found')\n // still reported as a run, so a reader waiting on a done line always gets one\n const run = agentRunStart(config, 0)\n agentDone(\n config, run, statusCodes.couldNotRun, 'no test files found',\n null, new Date().getTime() - startTime, 0\n )\n }\n\n // announced once the initial run is over, so `watching` marks a real milestone: startup is\n // complete and the watcher is live. A failed run is reported by listenToUser below.\n if (initialTestRun !== null) await initialTestRun.catch(() => null)\n\n agentOut(chalk.brightblue`watching...`)\n agentWatching(config, testFiles.size)\n\n const { listenToUser } = await import('./lib/listenToUser.js')\n const disposeTty = listenToUser(\n reRunManager,\n files => () => {\n return runTests(config, files, reRunManager, concurrency, 'refresh', runsOut, executionFilters)\n },\n config.watch.ttyActionsOnKeypress,\n initialTestRun,\n process.stdin,\n runsOut\n )\n stopFns.push(disposeTty)\n\n const dispose = () => {\n for (const stop of stopFns) {\n stop()\n }\n stopFns.length = 0 // Idempotencize\n }\n return dispose\n\n\n // (async () => {\n // await new Promise<void>(() => {})\n // })()\n //await new Promise<void>(() => {})\n}\n"]}
1
+ {"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/cli/watch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,0CAA0C;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CA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OAAO,EAAE,GAAG,SAAS,EAAE,CAAC,CAC5C,CAAA;IACL,CAAC;IAED,2FAA2F;IAC3F,oFAAoF;IACpF,IAAI,cAAc,KAAK,IAAI;QAAE,MAAM,cAAc,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;IAEnE,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAA,aAAa,CAAC,CAAA;IACvC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;IAErC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAA;IAC9D,MAAM,UAAU,GAAG,YAAY,CAC3B,YAAY,EACZ,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE;QACV,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;IACnG,CAAC,EACD,MAAM,CAAC,KAAK,CAAC,oBAAoB,EACjC,cAAc,EACd,KAAK,EACL,OAAO,CACV,CAAA;IACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAExB,MAAM,OAAO,GAAG,GAAG,EAAE;QACjB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YACzB,IAAI,EAAE,CAAA;QACV,CAAC;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA,CAAC,gBAAgB;IACvC,CAAC,CAAA;IACD,OAAO,OAAO,CAAA;IAGd,iBAAiB;IACjB,wCAAwC;IACxC,OAAO;IACP,mCAAmC;AACvC,CAAC","sourcesContent":["\nimport type { DependencyTrees, OutFn } from '../types.js'\nimport type { AllowedArguments } from './cliTypes.js'\nimport type { Concurrency } from './lib/runTests.js'\nimport chalk from '../packages/chalk.js'\nimport { packageName } from '../config.js'\nimport { out, debug } from '../output.js'\nimport { setEnv, setAgentEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\n//import { isTest } from './lib/isTest.js'\nimport { makeRunManagerState } from './lib/makeWatchRunState.js'\nimport { makeReRunManager } from './lib/reRunManager.js'\nimport { alwaysCacheBust } from './lib/alwaysCacheBust.js'\n\n\nexport type StopFn = () => void\n\nexport async function watch(): Promise<void> {\n await doWatch()\n await new Promise<void>(() => {})\n}\n\n// input is injectable so tests never read the terminal their runner is also reading\nexport async function doWatch(input: NodeJS.ReadStream = process.stdin): Promise<StopFn> {\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 isGlob: true\n },\n 'filter': {\n flag: 'f',\n hasValue: true,\n isGlob: true\n },\n 'filter-it': {\n flag: 'i',\n hasValue: true\n },\n 'filter-describe': {\n flag: 'd',\n hasValue: true\n },\n 'status-file': {\n flag: 's',\n hasValue: true\n },\n 'agent': {\n hasValue: false\n },\n 'compact': {\n hasValue: false\n }\n }\n const clArguments = parseCommandLineArguments(allowedClArguments)\n //debug('clArguments', clArguments)\n\n // agent mode owns stdout, so the banner and every later message below is routed through\n // agentOut - a sink in agent mode. Under the flag, init is announced before the config\n // loads, so a reader sees the process is alive even if startup is slow.\n const agentFlag = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentWatching, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentFlag)\n // the config can still turn agent mode on, so this is settled once it has loaded\n let agentMode = agentFlag\n const agentOut: OutFn = (...texts) => { if (!agentMode) out(...texts) }\n\n setEnv()\n\n const stopFns: StopFn[] = []\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 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 userConfig.testsFilter = filter\n }\n\n if ('status-file' in clArguments) {\n const statusFile = clArguments['status-file']\n if (typeof statusFile !== 'string' || statusFile === '') {\n throw new Error('No file path specified for --status-file or -s argument')\n }\n userConfig.watch = { ...userConfig.watch, statusFile }\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 const executionFilters = { it: filterIt, describe: filterDescribe }\n\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\n const config = applyConfigDefaults(userConfig)\n if (agentFlag) config.agent = true\n else if (config.agent) agentInit(true) // set by the config: announced once it has loaded\n agentMode = config.agent\n setAgentEnv(agentMode)\n const runsOut = (agentMode) ? agentSilentOut : undefined\n agentOut(chalk.brightblue`[${packageName}]...`)\n if (clArguments.compact === true) config.compact = true\n // there is no watch flag for it, and a config file must not enable it here: a truncated\n // run would still report covers=all, and failing files would drop out of `failing`\n config.failFast = false\n\n // not silenced in agent mode - a config error is fatal, so losing the message is worse\n // than breaking the one-line-per-event contract\n const { validateConfig } = await import('./lib/validateConfig.js')\n validateConfig(config)\n\n // no run has finished yet, so the status file starts at -1 rather than stale\n const { resetStatusFile, statusCodes, writeStatusFile } = await import('./lib/statusFile.js')\n resetStatusFile(config)\n\n const { doUserSetup } = await import('./lib/doUserSetup.js')\n await doUserSetup(config, agentOut)\n\n // watch mode never reaches an end of its own, so teardown only gets a chance on the way\n // out. Registered here so it pairs with the setup above and covers the initial run too.\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n const { registerShutdownHandlers } = await import('./lib/shutdown.js')\n \n const unregisterShutdownHandlers = registerShutdownHandlers(config, {\n teardown: doUserTeardown,\n exit: code => process.exit(code)\n })\n stopFns.push(unregisterShutdownHandlers)\n\n agentOut(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n debug(testFiles)\n agentFound(config, testFiles.size)\n\n // global store of the dependencies of tests\n let dependencyTrees: DependencyTrees = {}\n // store failing tests so we can re-run them.\n const failingTests: string[] = []\n \n const concurrency: Concurrency = { limit: -1 }\n\n const reRunManager = makeReRunManager(\n null,\n makeRunManagerState({\n allTestFiles: testFiles,\n lastTestFiles: testFiles\n }),\n runsOut\n )\n\n process.setSourceMapsEnabled(true) // enable source mapping\n\n if (testFiles.size > 0) {\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n // the trees are only consulted to narrow a run, so with evaluation off building them\n // is pure cost - and it is the slowest part of startup on a large suite\n if (config.watch.dependencyEvaluation) {\n const { buildDependencyTrees } = await import('./lib/buildDependencyTrees.js')\n agentOut(chalk.brightblue`finding initial dependency trees...`)\n dependencyTrees = buildDependencyTrees(config, testFiles)\n }\n }\n\n // live before the first test runs, for two reasons. A change landing during the initial\n // run (a compiler emit, typically) is seen rather than lost. And the watcher starts on a\n // quiet loop: node-watch probes for native recursive support with a 200ms timeout, and a\n // loop busy running tests fails the probe, so it falls back to a sync walk of every\n // directory - which then starved the tests' own timers (a 10ms interval fired once in 45ms)\n const { watchFilesAndRunTests } = await import('./lib/watchFilesAndRunTests.js')\n const stopWatcher = await watchFilesAndRunTests(\n config,\n //testFiles,\n dependencyTrees,\n failingTests, // CHECK this should also be in state\n reRunManager,\n //watchRunState,\n runsOut,\n executionFilters\n )\n stopFns.push(stopWatcher)\n\n const { runTests } = await import('./lib/runTests.js')\n let initialTestRun: Promise<boolean | null> | null = null\n if (testFiles.size > 0) {\n if (config.watch.runAllOnStartup) {\n agentOut(chalk.brightblue`running initial tests...`)\n initialTestRun = runTests(\n config, testFiles,\n reRunManager,\n concurrency,\n (alwaysCacheBust) ? 'refresh' : 'cached',\n runsOut, executionFilters\n ).then(testsResult => {\n const time = new Date().getTime() - startTime\n //await new Promise((resolve) => setTimeout(resolve, 100))\n agentOut(chalk.grey`\\n${time.toLocaleString()}ms`)\n return testsResult\n })\n reRunManager.state.currentRun = initialTestRun\n }\n } else {\n agentOut(chalk.orange`no test files found`)\n writeStatusFile(config, statusCodes.couldNotRun, 'no test files found')\n // still reported as a run, so a reader waiting on a done line always gets one\n const run = agentRunStart(config, 0)\n agentDone(\n config, run, statusCodes.couldNotRun, 'no test files found',\n null, new Date().getTime() - startTime, 0\n )\n }\n\n // announced once the initial run is over, so `watching` marks a real milestone: startup is\n // complete and the watcher is live. A failed run is reported by listenToUser below.\n if (initialTestRun !== null) await initialTestRun.catch(() => null)\n\n agentOut(chalk.brightblue`watching...`)\n agentWatching(config, testFiles.size)\n\n const { listenToUser } = await import('./lib/listenToUser.js')\n const disposeTty = listenToUser(\n reRunManager,\n files => () => {\n return runTests(config, files, reRunManager, concurrency, 'refresh', runsOut, executionFilters)\n },\n config.watch.ttyActionsOnKeypress,\n initialTestRun,\n input,\n runsOut\n )\n stopFns.push(disposeTty)\n\n const dispose = () => {\n for (const stop of stopFns) {\n stop()\n }\n stopFns.length = 0 // Idempotencize\n }\n return dispose\n\n\n // (async () => {\n // await new Promise<void>(() => {})\n // })()\n //await new Promise<void>(() => {})\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  export interface TimeProfiler {
2
2
  timeProfile: <T>(name: string, task: () => T) => T;
3
- timeProfileAsync: <T>(name: string, task: () => T | Promise<T>) => Promise<T>;
3
+ timeProfileAsync: <T>(name: string, task: () => Promise<T>) => Promise<T>;
4
4
  }
5
5
  export declare function createTimeProfiler(profiling?: boolean): TimeProfiler;
6
6
  //# sourceMappingURL=timeProfiler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timeProfiler.js","sourceRoot":"","sources":["../../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esContent":["\n// Local replacement for sxy-dev-tools' createTimeProfiler.\n// The upstream package's index eagerly imports sxy-standard + sxy-standard-object-copy\n// (global-patching side effects, ~108ms to load); this trivial reimplementation drops\n// that cost and the external dependency entirely.\n\nimport chalk from './chalk.js'\nimport { out } from '../output.js'\n\n\nexport interface TimeProfiler {\n timeProfile: <T>(name: string, task: () => T) => T\n timeProfileAsync: <T>(name: string, task: () => T | Promise<T>) => Promise<T>\n}\n\nexport function createTimeProfiler(profiling = true): TimeProfiler {\n if (!profiling) {\n return {\n timeProfile: (_name, task) => task(),\n timeProfileAsync: async (_name, task) => task()\n }\n }\n\n const report = (name: string, ms: number): void => {\n out(chalk.yellow`${name}` + ' - ' + chalk.orange`${ms.toLocaleString()}ms`)\n }\n\n return {\n timeProfile(name, task) {\n const start = Date.now()\n const result = task()\n report(name, Date.now() - start)\n return result\n },\n async timeProfileAsync(name, task) {\n const start = Date.now()\n const result = await task()\n report(name, Date.now() - start)\n return result\n }\n }\n}\n"]}
1
+ {"version":3,"file":"timeProfiler.js","sourceRoot":"","sources":["../../src/packages/timeProfiler.ts"],"names":[],"mappings":"AACA,2DAA2D;AAC3D,uFAAuF;AACvF,sFAAsF;AACtF,kDAAkD;AAElD,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAQlC,MAAM,UAAU,kBAAkB,CAAC,SAAS,GAAG,IAAI;IAC/C,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,OAAO;YACH,WAAW,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;YACpC,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;SAClD,CAAA;IACL,CAAC;IAED,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAU,EAAQ,EAAE;QAC9C,GAAG,CAAC,KAAK,CAAC,MAAM,CAAA,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,CAAA,GAAG,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;IAC/E,CAAC,CAAA;IAED,OAAO;QACH,WAAW,CAAC,IAAI,EAAE,IAAI;YAClB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YACxB,MAAM,MAAM,GAAG,IAAI,EAAE,CAAA;YACrB,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAA;YAChC,OAAO,MAAM,CAAA;QACjB,CAAC;QACD,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI;YAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YACxB,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,CAAA;YAC3B,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAA;YAChC,OAAO,MAAM,CAAA;QACjB,CAAC;KACJ,CAAA;AACL,CAAC","sourcesContent":["\n// Local replacement for sxy-dev-tools' createTimeProfiler.\n// The upstream package's index eagerly imports sxy-standard + sxy-standard-object-copy\n// (global-patching side effects, ~108ms to load); this trivial reimplementation drops\n// that cost and the external dependency entirely.\n\nimport chalk from './chalk.js'\nimport { out } from '../output.js'\n\n\nexport interface TimeProfiler {\n timeProfile: <T>(name: string, task: () => T) => T\n timeProfileAsync: <T>(name: string, task: () => Promise<T>) => Promise<T>\n}\n\nexport function createTimeProfiler(profiling = true): TimeProfiler {\n if (!profiling) {\n return {\n timeProfile: (_name, task) => task(),\n timeProfileAsync: async (_name, task) => task()\n }\n }\n\n const report = (name: string, ms: number): void => {\n out(chalk.yellow`${name}` + ' - ' + chalk.orange`${ms.toLocaleString()}ms`)\n }\n\n return {\n timeProfile(name, task) {\n const start = Date.now()\n const result = task()\n report(name, Date.now() - start)\n return result\n },\n async timeProfileAsync(name, task) {\n const start = Date.now()\n const result = await task()\n report(name, Date.now() - start)\n return result\n }\n }\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -37,7 +37,9 @@ export interface FinalConfig {
37
37
  teardown?: ConfigTasks;
38
38
  showErrorTrace: boolean;
39
39
  compact: boolean;
40
+ restateFailures: boolean;
40
41
  agent: boolean;
42
+ agentLineLengthLimit: number;
41
43
  failFast: boolean;
42
44
  execution: ExecutionConfig;
43
45
  watch: WatchConfig;