sxy-test-runner 2.4.7 → 2.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -114,7 +114,8 @@ npx sxy-test-runner once --filter-it "creates a user"
114
114
  # Stop at the first failure instead of running the whole suite
115
115
  npx sxy-test-runner once --fail-fast
116
116
 
117
- # Watch mode, reporting each run as single agent readable lines
117
+ # Report the run as single agent readable lines, in either mode
118
+ npx sxy-test-runner once --agent
118
119
  npx sxy-test-runner watch --agent
119
120
 
120
121
  # Watch mode, recording each run's result where another process can read it
@@ -133,10 +134,9 @@ and test names. They work in both watch and `once` modes and can be combined. If
133
134
  filters select no runnable tests, `once` exits `22` - `21` means no test file matched the
134
135
  `tests` pattern in the first place.
135
136
 
136
- `--agent` and `--status-file` are watch-only, and are the two ways to follow a watch session
137
- from outside it: `--agent` streams each run to stdout as single lines, `--status-file` writes
138
- the latest run's result to a file. Both are covered under "Watch mode" below. `once` ignores
139
- them - it already ends with an exit code.
137
+ `--agent` works in both modes and replaces the usual output with one line per event on
138
+ stdout - nothing else is printed, setup progress included. `--status-file` is watch-only,
139
+ writing the latest run's result to a file. Both are covered under "Watch mode" below.
140
140
 
141
141
  Describe and test filters run after the selected test files have loaded. The runner gives
142
142
  each test file a fresh ESM instance and propagates it through the file's static dependency
@@ -1,3 +1,3 @@
1
- import type { FinalConfig } from '../../types.js';
2
- export declare function doUserSetup(config: FinalConfig): Promise<void>;
1
+ import type { FinalConfig, OutFn } from '../../types.js';
2
+ export declare function doUserSetup(config: FinalConfig, progressOut?: OutFn): Promise<void>;
3
3
  //# sourceMappingURL=doUserSetup.d.ts.map
@@ -1,6 +1,9 @@
1
1
  import { join } from 'path';
2
2
  import { out } from '../../output.js';
3
- export async function doUserSetup(config) {
3
+ // progressOut carries the running-setup lines, so agent mode can sink them - they are
4
+ // progress, not events, and would break its one-line-per-event stream. The errors below stay
5
+ // on out: a broken setup entry is worth a stray line.
6
+ export async function doUserSetup(config, progressOut = out) {
4
7
  if (config.setup === undefined)
5
8
  return;
6
9
  const setupTasks = Array.isArray(config.setup) ? config.setup : [config.setup];
@@ -9,12 +12,12 @@ export async function doUserSetup(config) {
9
12
  for (const setupTask of setupTasks) {
10
13
  switch (typeof setupTask) {
11
14
  case 'function': {
12
- out('Running setup function ' + String(++setupFunctions));
15
+ progressOut('Running setup function ' + String(++setupFunctions));
13
16
  await setupTask();
14
17
  break;
15
18
  }
16
19
  case 'string': {
17
- out('Running setup file ' + String(++setupFiles) + ': ' + setupTask);
20
+ progressOut('Running setup file ' + String(++setupFiles) + ': ' + setupTask);
18
21
  await import(`file://${join(process.cwd(), setupTask)}`);
19
22
  break;
20
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"doUserSetup.js","sourceRoot":"","sources":["../../../src/cli/lib/doUserSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAGrC,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAmB;IACjD,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;QAAE,OAAM;IAEtC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC9E,IAAI,cAAc,GAAG,CAAC,CAAA;IACtB,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACjC,QAAQ,OAAO,SAAS,EAAE,CAAC;YACvB,KAAK,UAAU,CAAC,CAAC,CAAC;gBACd,GAAG,CAAC,yBAAyB,GAAG,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,CAAA;gBACzD,MAAM,SAAS,EAAE,CAAA;gBACjB,MAAK;YACT,CAAC;YACD,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACZ,GAAG,CAAC,qBAAqB,GAAG,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;gBACpE,MAAM,MAAM,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,EAAE,CAAC,CAAA;gBACxD,MAAK;YACT,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACN,GAAG,CAAC,mGAAmG,CAAC,CAAA;gBACxG,GAAG,CAAC,YAAY,OAAO,SAAS,GAAG,CAAC,CAAA;YACxC,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC","sourcesContent":["import { join } from 'path'\nimport { out } from '../../output.js'\nimport type { FinalConfig } from '../../types.js'\n\nexport async function doUserSetup(config: FinalConfig): Promise<void> {\n if (config.setup === undefined) return\n\n const setupTasks = Array.isArray(config.setup) ? config.setup : [config.setup]\n let setupFunctions = 0\n let setupFiles = 0\n for (const setupTask of setupTasks) {\n switch (typeof setupTask) {\n case 'function': {\n out('Running setup function ' + String(++setupFunctions))\n await setupTask()\n break\n }\n case 'string': {\n out('Running setup file ' + String(++setupFiles) + ': ' + setupTask)\n await import(`file://${join(process.cwd(), setupTask)}`)\n break\n }\n default: {\n out('Error: setup entry has an invalid type, expected \\'function\\' or \\'string\\' of an file to import.')\n out(`Received ${typeof setupTask}.`)\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"doUserSetup.js","sourceRoot":"","sources":["../../../src/cli/lib/doUserSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAGrC,sFAAsF;AACtF,6FAA6F;AAC7F,sDAAsD;AACtD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAmB,EAAE,cAAqB,GAAG;IAC3E,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;QAAE,OAAM;IAEtC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC9E,IAAI,cAAc,GAAG,CAAC,CAAA;IACtB,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACjC,QAAQ,OAAO,SAAS,EAAE,CAAC;YACvB,KAAK,UAAU,CAAC,CAAC,CAAC;gBACd,WAAW,CAAC,yBAAyB,GAAG,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,CAAA;gBACjE,MAAM,SAAS,EAAE,CAAA;gBACjB,MAAK;YACT,CAAC;YACD,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACZ,WAAW,CAAC,qBAAqB,GAAG,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;gBAC5E,MAAM,MAAM,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,EAAE,CAAC,CAAA;gBACxD,MAAK;YACT,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACN,GAAG,CAAC,mGAAmG,CAAC,CAAA;gBACxG,GAAG,CAAC,YAAY,OAAO,SAAS,GAAG,CAAC,CAAA;YACxC,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC","sourcesContent":["import { join } from 'path'\nimport { out } from '../../output.js'\nimport type { FinalConfig, OutFn } from '../../types.js'\n\n// progressOut carries the running-setup lines, so agent mode can sink them - they are\n// progress, not events, and would break its one-line-per-event stream. The errors below stay\n// on out: a broken setup entry is worth a stray line.\nexport async function doUserSetup(config: FinalConfig, progressOut: OutFn = out): Promise<void> {\n if (config.setup === undefined) return\n\n const setupTasks = Array.isArray(config.setup) ? config.setup : [config.setup]\n let setupFunctions = 0\n let setupFiles = 0\n for (const setupTask of setupTasks) {\n switch (typeof setupTask) {\n case 'function': {\n progressOut('Running setup function ' + String(++setupFunctions))\n await setupTask()\n break\n }\n case 'string': {\n progressOut('Running setup file ' + String(++setupFiles) + ': ' + setupTask)\n await import(`file://${join(process.cwd(), setupTask)}`)\n break\n }\n default: {\n out('Error: setup entry has an invalid type, expected \\'function\\' or \\'string\\' of an file to import.')\n out(`Received ${typeof setupTask}.`)\n }\n }\n }\n}\n"]}
package/dist/cli/once.js CHANGED
@@ -88,7 +88,7 @@ export async function once() {
88
88
  //console.log('run setup')
89
89
  //console.log(util.inspect(config))
90
90
  const { doUserSetup } = await import('./lib/doUserSetup.js');
91
- await doUserSetup(config);
91
+ await doUserSetup(config, agentOut);
92
92
  //console.log('ran setup')
93
93
  agentOut(chalk.brightblue(findingTestsMessage(config)));
94
94
  const { findTestFiles } = await import('./lib/findTestFiles.js');
@@ -1 +1 @@
1
- {"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/cli/once.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,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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AAC,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 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'\nimport { exitCodes } from './lib/exitCodes.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(exitCodes.noTestFiles)\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 // 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":"AACA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAGvC,OAAO,EAAE,MAAM,EAAE,MAA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CAAA;IACvD,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,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 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'\nimport { exitCodes } from './lib/exitCodes.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, 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 // 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 // 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"]}
package/dist/cli/watch.js CHANGED
@@ -99,7 +99,7 @@ export async function watch() {
99
99
  const { resetStatusFile, statusCodes, writeStatusFile } = await import('./lib/statusFile.js');
100
100
  resetStatusFile(config);
101
101
  const { doUserSetup } = await import('./lib/doUserSetup.js');
102
- await doUserSetup(config);
102
+ await doUserSetup(config, agentOut);
103
103
  // watch mode never reaches an end of its own, so teardown only gets a chance on the way
104
104
  // out. Registered here so it pairs with the setup above and covers the initial run too.
105
105
  const { doUserTeardown } = await import('./lib/doUserTeardown.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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AM;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"]}
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,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,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, 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 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sxy-test-runner",
3
- "version": "2.4.7",
3
+ "version": "2.4.8",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/RobertSandiford/sxy-test-runner",
6
6
  "repository": {