sxy-test-runner 2.4.3 → 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.
Files changed (39) hide show
  1. package/AGENTS.md +55 -9
  2. package/dist/cli/help.js +6 -4
  3. package/dist/cli/help.js.map +1 -1
  4. package/dist/cli/index.js +3 -23
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/cli/init.js +1 -0
  7. package/dist/cli/init.js.map +1 -1
  8. package/dist/cli/lib/agentReport.d.ts +1 -1
  9. package/dist/cli/lib/agentReport.js +5 -0
  10. package/dist/cli/lib/agentReport.js.map +1 -1
  11. package/dist/cli/lib/defaultConfig.js +1 -0
  12. package/dist/cli/lib/defaultConfig.js.map +1 -1
  13. package/dist/cli/lib/parseCommandLineArguments.d.ts +1 -0
  14. package/dist/cli/lib/parseCommandLineArguments.js +15 -1
  15. package/dist/cli/lib/parseCommandLineArguments.js.map +1 -1
  16. package/dist/cli/lib/resolveCommand.d.ts +8 -0
  17. package/dist/cli/lib/resolveCommand.js +47 -0
  18. package/dist/cli/lib/resolveCommand.js.map +1 -0
  19. package/dist/cli/lib/runDescribe.d.ts +2 -1
  20. package/dist/cli/lib/runDescribe.js +5 -2
  21. package/dist/cli/lib/runDescribe.js.map +1 -1
  22. package/dist/cli/lib/runDescribeRun.d.ts +2 -1
  23. package/dist/cli/lib/runDescribeRun.js +8 -2
  24. package/dist/cli/lib/runDescribeRun.js.map +1 -1
  25. package/dist/cli/lib/runTest.d.ts +2 -1
  26. package/dist/cli/lib/runTest.js +6 -2
  27. package/dist/cli/lib/runTest.js.map +1 -1
  28. package/dist/cli/lib/runTests.js +19 -4
  29. package/dist/cli/lib/runTests.js.map +1 -1
  30. package/dist/cli/lib/stopSignal.d.ts +7 -0
  31. package/dist/cli/lib/stopSignal.js +10 -0
  32. package/dist/cli/lib/stopSignal.js.map +1 -0
  33. package/dist/cli/once.js +33 -11
  34. package/dist/cli/once.js.map +1 -1
  35. package/dist/cli/watch.js +3 -0
  36. package/dist/cli/watch.js.map +1 -1
  37. package/dist/types.d.ts +3 -2
  38. package/dist/types.js.map +1 -1
  39. 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;AAMlC,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,QAAkB,EAAE,SAAyB;IAE7F,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,CAAC,IAAI,CAAC,eAAe,CAAA;QAErG,MAAM,UAAU,GAAG,gBAAgB,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,CAAA;QAE5E,MAAM,UAAU,GAA6B,EAAE,CAAA;QAC/C,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACnB,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,kBAAkB,EAAE,iBAAiB,CAAC,CAAA;YAC1E,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC1B,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AC","sourcesContent":["import { timeProfileAsync } from './timeProfier.js'\nimport { runTasks } from './runTasks.js'\nimport { debug } from '../../output.js'\nimport { runIt } from './runIt.js'\n\nimport type {\n FinalConfig, Describe, DescribeResult, ItResult, ItResultsSummary, ParsedDescribe, TaskExports\n} from '../../types.js'\n\nexport function runDescribeRun(config: FinalConfig, describe: Describe, parsedIts: ParsedDescribe)\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 const itPromise = runIt(config, it, beforeEachTestFunc, afterEachTestFunc)\n itPromises.push(itPromise)\n if (!isParallel) await itPromise\n }\n const itResults = await Promise.all(itPromises)\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
+ {"version":3,"file":"runDescribeRun.js","sourceRoot":"","sources":["../../../src/cli/lib/runDescribeRun.ts"],"names":[],"mappings":"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uB,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
@@ -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;AAM9C,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAElE,MAAM,UAAU,OAAO,CACnB,MAAmB,EACnB,IAAc,EACd,UAAgC,EAAE;IAElC,OAAO,gBAAgB,CAAC,YAAY,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,IAAI,EAAE;QACxD,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAEnB,uBAAuB;QACvB,MAAM,WAAW,GAAgB,EAAE,CAAA;QACnC,MAAM,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAE/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS;YAC5C,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,mBAAmB,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAA;QAErG,MAAM,UAAU,GAAG,gBAAgB,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,UAAU,CAAA;QAEhF,MAAM,mBAAmB,GAAmC,EAAE,CAAA;QAE9D,KAAK,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,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 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): 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 if (\n filters.describe !== undefined\n && !describe.thing.toLowerCase().includes(filters.describe.toLowerCase())\n ) continue\n\n const describePromise = runDescribe(config, describe, filters.it)\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"]}
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;AAE9C,OAAO,EAAE,cAAc,EAAmC,MAAM,iBAAiB,CAAA;AAMjF,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAElE,MAAM,UAAU,OAAO,CACnB,MAAmB,EACnB,IAAc,EACd,UAAgC,EAAE,EAClC,OAAmB,cAAc,EAAE;IAEnC,OAAO,gBAAgB,CAAC,YAAY,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,IAAI,EAAE;QACxD,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAEnB,uBAAuB;QACvB,MAAM,WAAW,GAAgB,EAAE,CAAA;QACnC,MAAM,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAE/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS;YAC5C,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,mBAAmB,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAA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C,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"]}
@@ -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,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,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAK9D,OAAO,EAAE,mBAAmB,EAAoB,MAAM,wBAAwB,CAAA;AAG9E,MAAM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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,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAK9D,OAAO,EAAE,mBAAmB,EAAoB,MAAM,wBAAwB,CAAA;AAG9E,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAIlE,8DAA8D;AAC9D,SAAS,SAAS,CAAC,GAAG,KAAe;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CAAC,gBAAgB,EAAE,MAAM,EAAE,QAAQ,CAAC;iBAC7C,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC;sBACxD,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;gBAE9D,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 { 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"]}
@@ -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
- // agent reporting is a watch mode concern - `once` already ends with an exit code, so a
67
- // config setting it must not leak in here
68
- config.watch.agent = false;
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
- out(chalk.brightblue(findingTestsMessage(config)));
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
- out(chalk.mediumred(`[${packageName}] Found no tests.`
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
- out(chalk.brightblue(`[${packageName}] time: ${time.toLocaleString()}ms`));
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
- out(chalk.brightblue(foundTestsMessage(testFiles.size)));
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
- log(chalk.brightblue `running tests...`);
96
- const testsResult = await runTests(config, testFiles, undefined, (isTest) ? 'refresh' : 'cached', undefined, {
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
- out(chalk.grey `\n${time.toLocaleString()}ms\n`);
125
+ agentOut(chalk.grey `\n${time.toLocaleString()}ms\n`);
104
126
  const { doUserTeardown } = await import('./lib/doUserTeardown.js');
105
127
  await doUserTeardown(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AE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAA;QAClE,MAAM,cAAc,CAAC,MAAM,CAAC,CAAA;QAE5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC;IAED,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAExD,8EAA8E;IAC9E,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAA;IACtD,GAAG,CAAC,KAAK,CAAC,UAAU,CAAA,kBAAkB,CAAC,CAAA;IACvC,MAAM,WAAW,GAAG,MAAM,QAAQ,CAC9B,MAAM,EAAE,SAAS,EACjB,SAAS,EACT,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAC/B,SAAS,EACT;QACI,EAAE,EAAE,QAAQ;QACZ,QAAQ,EAAE,cAAc;KAC3B,CACJ,CAAA;IACD,yFAAyF;IACzF,MAAM,QAAQ,GAAG,WAAW,KAAK,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,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,MAAM,WAAW,GAAG,MAAM,QAAQ,CAC9B,MAAM,EAAE,SAAS,EACjB,SAAS,EACT,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAC/B,OAAO,EACP;QACI,EAAE,EAAE,QAAQ;QACZ,QAAQ,EAAE,cAAc;KAC3B,CACJ,CAAA;IACD,yFAAyF;IACzF,MAAM,QAAQ,GAAG,WAAW,KAAK,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,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 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');
@@ -1 +1 @@
1
- {"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/cli/watch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAGzC,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;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD,MAAM,CAAC,KAAK,UAAU,KAAK;IACvB,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,QAAQ,EAAE;YACN,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,YAAY,EAAE;YACV,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,QAAQ,EAAE;YACN,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,WAAW,EAAE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uBAAuB,CAAC,CAAA;IAC9D,YAAY,CACR,YAAY,EACZ,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE;QACV,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;IACtF,CAAC,EACD,MAAM,CAAC,KAAK,CAAC,oBAAoB,EACjC,cAAc,EACd,OAAO,CAAC,KAAK,EACb,OAAO,CACV,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;IAGzB,0FAA0F;IAC1F,+CAA+C;IAC/C,MAAM,IAAI,OAAO,CAAO,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;AACrC,CAAC","sourcesContent":["import chalk from '../packages/chalk.js'\n\nimport { packageName } from '../config.js'\nimport { out, debug } from '../output.js'\n\nimport type { AllowedArguments, DependencyTrees, 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'\nimport { makeRunManagerState } from './lib/makeWatchRunState.js'\nimport { makeReRunManager } from './lib/reRunManager.js'\n\nexport async function watch(): 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 'status-file': {\n flag: 's',\n hasValue: true\n },\n 'agent': {\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 when the flag is on. Announced before the config loads, so a reader\n // sees the process is alive even if startup is slow.\n const agentMode = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentWatching, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentMode)\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 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 (agentMode) config.watch.agent = true\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)\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 registerShutdownHandlers(config, {\n teardown: doUserTeardown,\n exit: code => process.exit(code)\n })\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 reRunManager = makeReRunManager(\n null,\n makeRunManagerState({\n allTestFiles: testFiles,\n lastTestFiles: testFiles\n }),\n runsOut\n )\n\n const { runTests } = await import('./lib/runTests.js')\n let initialTestRun: Promise<boolean | null> | null = null\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 if (config.watch.runAllOnStartup) {\n agentOut(chalk.brightblue`running initial tests...`)\n initialTestRun = runTests(\n config, testFiles, reRunManager,\n (isTest) ? 'refresh' : 'cached',\n runsOut, executionFilters\n ).then(async 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 // do we need to catch errors like this?\n initialTestRun.catch(err => `Error during initial test run: ${err}`)\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 const { watchFilesAndRunTests } = await import('./lib/watchFilesAndRunTests.js')\n 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\n\n agentOut(chalk.brightblue`watching...`)\n agentWatching(config, testFiles.size)\n\n const { listenToUser } = await import('./lib/listenToUser.js')\n listenToUser(\n reRunManager,\n files => () => {\n return runTests(config, files, reRunManager, 'refresh', runsOut, executionFilters)\n },\n config.watch.ttyActionsOnKeypress,\n initialTestRun,\n process.stdin,\n runsOut\n ).catch(e => { throw e })\n\n\n // park forever - watch mode ends by being signalled, and the shutdown handlers registered\n // above run the user's teardown on the way out\n await new Promise<void>(() => {})\n}\n"]}
1
+ {"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/cli/watch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAGzC,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;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD,MAAM,CAAC,KAAK,UAAU,KAAK;IACvB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAA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C,CAC5C,CAAA;IACL,CAAC;IAED,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,MAAM,CAAC,gCAAgC,CAAC,CAAA;IAChF,MAAM,qBAAqB,CACvB,MAAM;IACN,YAAY;IACZ,eAAe,EACf,YAAY,EAAE,qCAAqC;IACnD,YAAY;IACZ,gBAAgB;IAChB,OAAO,EACP,gBAAgB,CACnB,CAAA;IAGD,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,YAAY,CACR,YAAY,EACZ,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE;QACV,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;IACtF,CAAC,EACD,MAAM,CAAC,KAAK,CAAC,oBAAoB,EACjC,cAAc,EACd,OAAO,CAAC,KAAK,EACb,OAAO,CACV,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;IAGzB,0FAA0F;IAC1F,+CAA+C;IAC/C,MAAM,IAAI,OAAO,CAAO,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;AACrC,CAAC","sourcesContent":["import chalk from '../packages/chalk.js'\n\nimport { packageName } from '../config.js'\nimport { out, debug } from '../output.js'\n\nimport type { AllowedArguments, DependencyTrees, 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'\nimport { makeRunManagerState } from './lib/makeWatchRunState.js'\nimport { makeReRunManager } from './lib/reRunManager.js'\n\nexport async function watch(): 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 'status-file': {\n flag: 's',\n hasValue: true\n },\n 'agent': {\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 when the flag is on. Announced before the config loads, so a reader\n // sees the process is alive even if startup is slow.\n const agentMode = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentWatching, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentMode)\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 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 (agentMode) config.watch.agent = 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)\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 registerShutdownHandlers(config, {\n teardown: doUserTeardown,\n exit: code => process.exit(code)\n })\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 reRunManager = makeReRunManager(\n null,\n makeRunManagerState({\n allTestFiles: testFiles,\n lastTestFiles: testFiles\n }),\n runsOut\n )\n\n const { runTests } = await import('./lib/runTests.js')\n let initialTestRun: Promise<boolean | null> | null = null\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 if (config.watch.runAllOnStartup) {\n agentOut(chalk.brightblue`running initial tests...`)\n initialTestRun = runTests(\n config, testFiles, reRunManager,\n (isTest) ? 'refresh' : 'cached',\n runsOut, executionFilters\n ).then(async 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 // do we need to catch errors like this?\n initialTestRun.catch(err => `Error during initial test run: ${err}`)\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 const { watchFilesAndRunTests } = await import('./lib/watchFilesAndRunTests.js')\n 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\n\n agentOut(chalk.brightblue`watching...`)\n agentWatching(config, testFiles.size)\n\n const { listenToUser } = await import('./lib/listenToUser.js')\n listenToUser(\n reRunManager,\n files => () => {\n return runTests(config, files, reRunManager, 'refresh', runsOut, executionFilters)\n },\n config.watch.ttyActionsOnKeypress,\n initialTestRun,\n process.stdin,\n runsOut\n ).catch(e => { throw e })\n\n\n // park forever - watch mode ends by being signalled, and the shutdown handlers registered\n // above run the user's teardown on the way out\n await new Promise<void>(() => {})\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -38,14 +38,15 @@ export interface FinalConfig {
38
38
  teardown?: ConfigTasks;
39
39
  showErrorTrace: boolean;
40
40
  compact: boolean;
41
+ failFast: boolean;
41
42
  execution: ExecutionConfig;
42
43
  watch: WatchConfig;
43
44
  }
44
- export type UserConfig = Partial<Omit<FinalConfig, 'testsFilter' | 'execution' | 'watch'>> & {
45
+ export type UserConfig = Partial<Omit<FinalConfig, 'testsFilter' | 'failFast' | 'execution' | 'watch'>> & {
45
46
  execution?: Partial<ExecutionConfig>;
46
47
  watch?: Partial<WatchConfig>;
47
48
  };
48
- export type UserConfigInternal = UserConfig & Partial<Pick<FinalConfig, 'testsFilter'>>;
49
+ export type UserConfigInternal = UserConfig & Partial<Pick<FinalConfig, 'testsFilter' | 'failFast'>>;
49
50
  export type TestParcel = TaskExports;
50
51
  export interface DescribeParcel extends TaskExports {
51
52
  it: (should: string, test: (parcel: TestParcel) => void | Promise<void>) => void;