sxy-test-runner 2.3.19 → 2.3.20

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
@@ -249,6 +249,47 @@ Important limitations:
249
249
  - Use `once` instead of watch mode for autonomous agent verification so the command
250
250
  terminates and returns a meaningful status.
251
251
 
252
+ ### Watching someone else's watch session
253
+
254
+ `--status-file <file>` (`-s`, or `watch.statusFile` in the config) makes watch mode record
255
+ each run's result where another process can read it, rather than in the terminal only. The
256
+ first line is `<code> - <description>`, the second is when the run finished, then the summary,
257
+ then any failures, with the run's duration last:
258
+
259
+ ```
260
+ 1 - 2 tests failed
261
+ 2026-08-03 20:14:52 +01:00
262
+ Tests: 8/10
263
+ Items: 4/5
264
+ Test Files: 1/2
265
+ Failures:
266
+ f: tests/users.test.js
267
+ d: creating a user
268
+ t: rejects a duplicate email
269
+ e: AssertionError: expected 409 to equal 200
270
+ t: sends a welcome email
271
+ e: Error: connect ECONNREFUSED 127.0.0.1:2525
272
+ 1,204ms
273
+ ```
274
+
275
+ Failures nest as `f:` file, `d:` describe, `t:` test, `e:` error - one line each. A file that
276
+ would not load gives `e: did not load: <error>` under its `f:` line, and a describe that
277
+ threw gives `e: threw: <error>` under its `d:` line. Diffs, logs and stack traces are only in
278
+ the terminal output.
279
+
280
+ | code | meaning |
281
+ | --- | --- |
282
+ | -1 | watch mode has started, but no run has finished |
283
+ | 0 | everything passed |
284
+ | 1 | tests ran and failed |
285
+ | 2 | the run died partway - a test file would not load, or a describe threw |
286
+ | 3 | nothing ran - no test files were found, or the filters matched nothing |
287
+
288
+ Code `2` is worth handling separately from `1`: it usually means the suite broke rather
289
+ than the code under test. Watch mode writes `-1` on startup, so a status from a previous
290
+ session is never read as current, and each write is renamed into place, so a poller only
291
+ ever sees a complete status.
292
+
252
293
  ## Configuration reference
253
294
 
254
295
  The exported config type is available for JavaScript type checking:
@@ -284,7 +325,8 @@ export default {
284
325
  watchFilesIgnore: '**/node_modules/**',
285
326
  runAllOnStartup: true,
286
327
  reRunFailingTests: true,
287
- ttyActionsOnKeypress: false
328
+ ttyActionsOnKeypress: false,
329
+ statusFile: false
288
330
  }
289
331
  }
290
332
  ```
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Robert Sandiford
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/cli/help.js CHANGED
@@ -29,6 +29,7 @@ export function help() {
29
29
  ' -f, --filter <glob> Further constrain the configured test pattern',
30
30
  ' -d, --filter-describe <substring> Run matching describe blocks',
31
31
  ' -i, --filter-it <substring> Run matching tests',
32
+ ' -s, --status-file <file> Write the latest watch run status to a file',
32
33
  '',
33
34
  'Watch controls:',
34
35
  ' r/l + Enter Re-run the last set of tests',
@@ -44,7 +45,7 @@ export function help() {
44
45
  ` ${cliName} once --config config/sxyt.config.js`,
45
46
  '',
46
47
  `Configuration: ${configNames} in ${configDirectories}.`,
47
- `Executable aliases: sxyt, ${cliName}, ${packageName}.`
48
+ `Executable aliases: ${cliName}, sxy-test, ${packageName}.`
48
49
  ].join('\n'));
49
50
  }
50
51
  //# sourceMappingURL=help.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACrF,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAElC,MAAM,UAAU,IAAI;IAChB,MAAM,WAAW,GAAG,eAAe;SAC9B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,eAAe,CAAC;SACnC,IAAI,CAAC,MAAM,CAAC,CAAA;IACjB,MAAM,iBAAiB,GAAG,eAAe;SACpC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;SACtE,IAAI,CAAC,MAAM,CAAC,CAAA;IAEjB,GAAG,CAAC;QACA,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;QAC7B,EAAE;QACF,QAAQ;QACR,KAAK,OAAO,oBAAoB;QAChC,KAAK,OAAO,iBAAiB;QAC7B,KAAK,OAAO,OAAO;QACnB,KAAK,OAAO,OAAO;QACnB,EAAE;QACF,WAAW;QACX,iEAAiE;QACjE,2CAA2C;QAC3C,+CAA+C;QAC/C,yBAAyB;QACzB,EAAE;QACF,UAAU;QACV,8DAA8D;QAC9D,iEAAiE;QACjE,0EAA0E;QAC1E,mEAAmE;QACnE,yDAAyD;QACzD,EAAE;QACF,iBAAiB;QACjB,sDAAsD;QACtD,0CAA0C;QAC1C,8CAA8C;QAC9C,qEAAqE;QACrE,EAAE;QACF,WAAW;QACX,KAAK,OAAO,EAAE;QACd,KAAK,OAAO,OAAO;QACnB,KAAK,OAAO,4CAA4C;QACxD,KAAK,OAAO,8BAA8B;QAC1C,KAAK,OAAO,sCAAsC;QAClD,EAAE;QACF,kBAAkB,WAAW,OAAO,iBAAiB,GAAG;QACxD,6BAA6B,OAAO,KAAK,WAAW,GAAG;KAC1D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AACjB,CAAC","sourcesContent":["import chalk from '../packages/chalk.js'\nimport { packageName, cliName, configFileNames, configLocations } from '../config.js'\nimport { out } from '../output.js'\n\nexport function help(): void {\n const configNames = configFileNames\n .map(name => `${name}.{js,cjs,mjs}`)\n .join(' or ')\n const configDirectories = configLocations\n .map(location => location === '' ? 'the project root' : `${location}/`)\n .join(' or ')\n\n out([\n chalk.brightblue(packageName),\n '',\n 'Usage:',\n ` ${cliName} [watch] [options]`,\n ` ${cliName} once [options]`,\n ` ${cliName} init`,\n ` ${cliName} help`,\n '',\n 'Commands:',\n ' watch Run tests and watch for related file changes (default)',\n ' once Run the test suite once and exit',\n ' init Create an initial configuration file',\n ' help Show this help',\n '',\n 'Options:',\n ' -c, --config <file> Use a specific configuration file',\n ' -t, --test-files <glob> Override the configured test pattern',\n ' -f, --filter <glob> Further constrain the configured test pattern',\n ' -d, --filter-describe <substring> Run matching describe blocks',\n ' -i, --filter-it <substring> Run matching tests',\n '',\n 'Watch controls:',\n ' r/l + Enter Re-run the last set of tests',\n ' a + Enter Re-run all tests',\n ' f + Enter Re-run failing tests',\n ' Set watch.ttyActionsOnKeypress to true to run these without Enter',\n '',\n 'Examples:',\n ` ${cliName}`,\n ` ${cliName} once`,\n ` ${cliName} watch --test-files \"**/*.focused.test.js\"`,\n ` ${cliName} once --filter \"**/users/**\"`,\n ` ${cliName} once --config config/sxyt.config.js`,\n '',\n `Configuration: ${configNames} in ${configDirectories}.`,\n `Executable aliases: sxyt, ${cliName}, ${packageName}.`\n ].join('\\n'))\n}\n"]}
1
+ {"version":3,"file":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BAAiB,GAAG;QACxD,uBAAuB,OAAO,eAAe,WAAW,GAAG;KAC9D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AACjB,CAAC","sourcesContent":["import chalk from '../packages/chalk.js'\nimport { packageName, cliName, configFileNames, configLocations } from '../config.js'\nimport { out } from '../output.js'\n\nexport function help(): void {\n const configNames = configFileNames\n .map(name => `${name}.{js,cjs,mjs}`)\n .join(' or ')\n const configDirectories = configLocations\n .map(location => location === '' ? 'the project root' : `${location}/`)\n .join(' or ')\n\n out([\n chalk.brightblue(packageName),\n '',\n 'Usage:',\n ` ${cliName} [watch] [options]`,\n ` ${cliName} once [options]`,\n ` ${cliName} init`,\n ` ${cliName} help`,\n '',\n 'Commands:',\n ' watch Run tests and watch for related file changes (default)',\n ' once Run the test suite once and exit',\n ' init Create an initial configuration file',\n ' help Show this help',\n '',\n 'Options:',\n ' -c, --config <file> Use a specific configuration file',\n ' -t, --test-files <glob> Override the configured test pattern',\n ' -f, --filter <glob> Further constrain the configured test pattern',\n ' -d, --filter-describe <substring> Run matching describe blocks',\n ' -i, --filter-it <substring> Run matching tests',\n ' -s, --status-file <file> Write the latest watch run status to a file',\n '',\n 'Watch controls:',\n ' r/l + Enter Re-run the last set of tests',\n ' a + Enter Re-run all tests',\n ' f + Enter Re-run failing tests',\n ' Set watch.ttyActionsOnKeypress to true to run these without Enter',\n '',\n 'Examples:',\n ` ${cliName}`,\n ` ${cliName} once`,\n ` ${cliName} watch --test-files \"**/*.focused.test.js\"`,\n ` ${cliName} once --filter \"**/users/**\"`,\n ` ${cliName} once --config config/sxyt.config.js`,\n '',\n `Configuration: ${configNames} in ${configDirectories}.`,\n `Executable aliases: ${cliName}, sxy-test, ${packageName}.`\n ].join('\\n'))\n}\n"]}
package/dist/cli/init.js CHANGED
@@ -126,6 +126,9 @@ export default {
126
126
  // run watch mode keyboard commands immediately, without waiting for Enter
127
127
  ttyActionsOnKeypress: false,
128
128
 
129
+ // file to write the latest run status to, or false for none
130
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esContent":["import { join } from 'path'\nimport chalk from '../packages/chalk.js'\nimport { packageName, cliName, configFileNames, configLocations } from '../config.js'\nimport { out } from '../output.js'\nimport fs from 'fs'\n\nexport function init(): void {\n const projectDir = process.cwd()\n\n for (const configLocation of configLocations) {\n for (const configFileName of configFileNames) {\n let loc\n loc = join(projectDir, configLocation, configFileName + '.js')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n loc = join(projectDir, configLocation, configFileName + '.cjs')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n loc = join(projectDir, configLocation, configFileName + '.mjs')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n }\n }\n\n function configAlreadyExists(loc: string): void {\n out(chalk.orange`[${packageName}] A matching config already exists at ${loc}`\n + `\\nPlease remove this config before generating a new one with \\`${cliName} init\\``)\n }\n\n const projectPackageJsonLocation = join(projectDir, 'package.json')\n if (!fs.existsSync(projectPackageJsonLocation)) {\n out(chalk.orange`[${packageName}] No package.json exists in this location`\n + '\\nPlease initialise the package with `yarn init` on `npm init`'\n + ' before running this command, and run this command from the project root folder')\n }\n\n const packageJsonRaw = fs.readFileSync(projectPackageJsonLocation, 'utf8')\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const packageJson: { type?: string } = JSON.parse(packageJsonRaw)\n\n const targetConfigName = (packageJson.type === 'module')\n // ES6 module\n ? join(projectDir, configLocations[0] ?? '', configFileNames[0] + '.js')\n // common\n : join(projectDir, configLocations[0] ?? '', configFileNames[0] + '.mjs')\n\n const defaultConfig =\n`\n// @ts-check\n\n/** @satisfies {import('sxy-test-runner').Config} */\nexport default {\n\n // base folder for tests match and ignore patterns\n testsBase: '.',\n\n // glob pattern or array of glob patterns of test files\n tests: [\n '**/*.sxyt.{js,mjs,jsx}',\n '**/*.test.{js,mjs,jsx}',\n '**/*.spec.{js,mjs,jsx}',\n '**/tests?/*.{js,mjs,jsx}',\n '**/__tests?__/*.{js,mjs,jsx}'\n ],\n\n // glob pattern or array of patterns of test files to ignore\n testsIgnore: ['**/node_modules/**/*'],\n\n // whether to show the full error trace when an error occurs in a test file\n showErrorTrace: false,\n\n // tasks to run on startup\n // accepts a function, file location (relative to project base), or array of functions and or files\n setup: undefined,\n\n // tasks to run before each test file is run\n beforeEachFile: undefined,\n\n // tasks to run after each test file is run\n afterEachFile: undefined,\n\n // tasks to run before each describe block is processed\n // if the function returns an object with named properties, or the file exports named exports,\n // these will be passed to the callback function in argument 0, and can be access by destructruing e.g.\n // describe('thing', ({exportA, exportB}) => { it('should', ...) })\n beforeEachDescribe: undefined,\n\n // tasks to run after each describe block\n afterEachDescribe: undefined,\n\n // tasks to run before each it/test block\n // function returns and file exports will be passed to the it/test block as with describe above, e.g.\n // it('should', ({exportA, exportB}) => { assert('something') })\n beforeEachTest: undefined,\n\n // tasks to run after each it/test block\n afterEachTest: undefined,\n\n // how to execute the different parts of test files\n execution: {\n\n // run test files in 'parallel' or 'sequential'ly\n files: 'sequential',\n\n // run describe blocks within a test file in 'parallel' or 'sequential'ly\n describes: 'sequential',\n\n // run it/test blocks within a describe blocks in 'parallel' or 'sequential'ly\n tests: 'sequential'\n\n },\n\n // watch mode configurations\n watch: {\n\n //// the base directory to watch files in\n watchFilesBase: '.',\n\n //// glob filter or array of glob filters of files to watch\n watchFiles: '**/*.js',\n\n //// glob filter or array of globl filters of files to ignore\n watchFilesIgnore: '**/node_modules/**/*',\n\n // run all tests when starting the watcher\n runAllOnStartup: true,\n\n // re run all previously failed tests on each test run, until they pass\n reRunFailingTests: true,\n\n // run watch mode keyboard commands immediately, without waiting for Enter\n ttyActionsOnKeypress: false,\n\n },\n\n}`\n\n fs.writeFileSync(targetConfigName, defaultConfig)\n\n out(chalk.mediumgreen`[${packageName}] Created config at ` + chalk.blue(targetConfigName))\n}\n"]}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA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,cAAc,CAAC,CAAA;IACnE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE,CAAC;QAC7C,GAAG,CAAC,KAAK,CAAC,MAAM,CAAA,IAAI,WAAW,2CAA2C;cACpE,gEAAgE;cAChE,iFAAiF,CAAC,CAAA;IAC5F,CAAC;IAED,MAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAA;IAC1E,mEAAmE;IACnE,MAAM,WAAW,GAAsB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;IAEjE,MAAM,gBAAgB,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,CAAC;QACpD,aAAa;QACb,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;QACxE,SAAS;QACT,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAA;IAE7E,MAAM,aAAa,GACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2FE,CAAA;IAEE,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA;IAEjD,GAAG,CAAC,KAAK,CAAC,WAAW,CAAA,IAAI,WAAW,sBAAsB,GAAG,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAC9F,CAAC","sourcesContent":["import { join } from 'path'\nimport chalk from '../packages/chalk.js'\nimport { packageName, cliName, configFileNames, configLocations } from '../config.js'\nimport { out } from '../output.js'\nimport fs from 'fs'\n\nexport function init(): void {\n const projectDir = process.cwd()\n\n for (const configLocation of configLocations) {\n for (const configFileName of configFileNames) {\n let loc\n loc = join(projectDir, configLocation, configFileName + '.js')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n loc = join(projectDir, configLocation, configFileName + '.cjs')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n loc = join(projectDir, configLocation, configFileName + '.mjs')\n if (fs.existsSync(loc)) {\n configAlreadyExists(loc)\n }\n }\n }\n\n function configAlreadyExists(loc: string): void {\n out(chalk.orange`[${packageName}] A matching config already exists at ${loc}`\n + `\\nPlease remove this config before generating a new one with \\`${cliName} init\\``)\n }\n\n const projectPackageJsonLocation = join(projectDir, 'package.json')\n if (!fs.existsSync(projectPackageJsonLocation)) {\n out(chalk.orange`[${packageName}] No package.json exists in this location`\n + '\\nPlease initialise the package with `yarn init` on `npm init`'\n + ' before running this command, and run this command from the project root folder')\n }\n\n const packageJsonRaw = fs.readFileSync(projectPackageJsonLocation, 'utf8')\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const packageJson: { type?: string } = JSON.parse(packageJsonRaw)\n\n const targetConfigName = (packageJson.type === 'module')\n // ES6 module\n ? join(projectDir, configLocations[0] ?? '', configFileNames[0] + '.js')\n // common\n : join(projectDir, configLocations[0] ?? '', configFileNames[0] + '.mjs')\n\n const defaultConfig =\n`\n// @ts-check\n\n/** @satisfies {import('sxy-test-runner').Config} */\nexport default {\n\n // base folder for tests match and ignore patterns\n testsBase: '.',\n\n // glob pattern or array of glob patterns of test files\n tests: [\n '**/*.sxyt.{js,mjs,jsx}',\n '**/*.test.{js,mjs,jsx}',\n '**/*.spec.{js,mjs,jsx}',\n '**/tests?/*.{js,mjs,jsx}',\n '**/__tests?__/*.{js,mjs,jsx}'\n ],\n\n // glob pattern or array of patterns of test files to ignore\n testsIgnore: ['**/node_modules/**/*'],\n\n // whether to show the full error trace when an error occurs in a test file\n showErrorTrace: false,\n\n // tasks to run on startup\n // accepts a function, file location (relative to project base), or array of functions and or files\n setup: undefined,\n\n // tasks to run before each test file is run\n beforeEachFile: undefined,\n\n // tasks to run after each test file is run\n afterEachFile: undefined,\n\n // tasks to run before each describe block is processed\n // if the function returns an object with named properties, or the file exports named exports,\n // these will be passed to the callback function in argument 0, and can be access by destructruing e.g.\n // describe('thing', ({exportA, exportB}) => { it('should', ...) })\n beforeEachDescribe: undefined,\n\n // tasks to run after each describe block\n afterEachDescribe: undefined,\n\n // tasks to run before each it/test block\n // function returns and file exports will be passed to the it/test block as with describe above, e.g.\n // it('should', ({exportA, exportB}) => { assert('something') })\n beforeEachTest: undefined,\n\n // tasks to run after each it/test block\n afterEachTest: undefined,\n\n // how to execute the different parts of test files\n execution: {\n\n // run test files in 'parallel' or 'sequential'ly\n files: 'sequential',\n\n // run describe blocks within a test file in 'parallel' or 'sequential'ly\n describes: 'sequential',\n\n // run it/test blocks within a describe blocks in 'parallel' or 'sequential'ly\n tests: 'sequential'\n\n },\n\n // watch mode configurations\n watch: {\n\n //// the base directory to watch files in\n watchFilesBase: '.',\n\n //// glob filter or array of glob filters of files to watch\n watchFiles: '**/*.js',\n\n //// glob filter or array of globl filters of files to ignore\n watchFilesIgnore: '**/node_modules/**/*',\n\n // run all tests when starting the watcher\n runAllOnStartup: true,\n\n // re run all previously failed tests on each test run, until they pass\n reRunFailingTests: true,\n\n // run watch mode keyboard commands immediately, without waiting for Enter\n ttyActionsOnKeypress: false,\n\n // file to write the latest run status to, or false for none\n statusFile: false,\n\n },\n\n}`\n\n fs.writeFileSync(targetConfigName, defaultConfig)\n\n out(chalk.mediumgreen`[${packageName}] Created config at ` + chalk.blue(targetConfigName))\n}\n"]}
@@ -21,7 +21,8 @@ export const defaultConfig = {
21
21
  watchFilesIgnore: '**/node_modules/**/*',
22
22
  runAllOnStartup: true,
23
23
  reRunFailingTests: true,
24
- ttyActionsOnKeypress: false
24
+ ttyActionsOnKeypress: false,
25
+ statusFile: false
25
26
  }
26
27
  };
27
28
  //# sourceMappingURL=defaultConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../../../src/cli/lib/defaultConfig.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAgB;IACtC,SAAS,EAAE,GAAG;IACd,KAAK,EAAE;QACH,wBAAwB;QACxB,wBAAwB;QACxB,wBAAwB;QACxB,0BAA0B;QAC1B,8BAA8B;KACjC;IACD,WAAW,EAAE,CAAC,sBAAsB,CAAC;IACrC,cAAc,EAAE,KAAK;IACrB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE;QACP,KAAK,EAAE,YAAY;QACnB,SAAS,EAAE,YAAY;QACvB,KAAK,EAAE,YAAY;KACtB;IACD,KAAK,EAAE;QACH,cAAc,EAAE,GAAG;QACnB,UAAU,EAAE,SAAS;QACrB,gBAAgB,EAAE,sBAAsB;QACxC,eAAe,EAAE,IAAI;QACrB,iBAAiB,EAAE,IAAI;QACvB,oBAAoB,EAAE,KAAK;KAC9B;CACJ,CAAA","sourcesContent":["import type { FinalConfig } from '../../types.js'\n\nexport const defaultConfig: FinalConfig = {\n testsBase: '.',\n tests: [\n '**/*.sxyt.{js,mjs,jsx}',\n '**/*.test.{js,mjs,jsx}',\n '**/*.spec.{js,mjs,jsx}',\n '**/tests?/*.{js,mjs,jsx}',\n '**/__tests?__/*.{js,mjs,jsx}'\n ],\n testsIgnore: ['**/node_modules/**/*'],\n showErrorTrace: false,\n compact: false,\n execution: {\n files: 'sequential',\n describes: 'sequential',\n tests: 'sequential'\n },\n watch: {\n watchFilesBase: '.',\n watchFiles: '**/*.js',\n watchFilesIgnore: '**/node_modules/**/*',\n runAllOnStartup: true,\n reRunFailingTests: true,\n ttyActionsOnKeypress: false\n }\n}\n"]}
1
+ {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../../../src/cli/lib/defaultConfig.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAgB;IACtC,SAAS,EAAE,GAAG;IACd,KAAK,EAAE;QACH,wBAAwB;QACxB,wBAAwB;QACxB,wBAAwB;QACxB,0BAA0B;QAC1B,8BAA8B;KACjC;IACD,WAAW,EAAE,CAAC,sBAAsB,CAAC;IACrC,cAAc,EAAE,KAAK;IACrB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE;QACP,KAAK,EAAE,YAAY;QACnB,SAAS,EAAE,YAAY;QACvB,KAAK,EAAE,YAAY;KACtB;IACD,KAAK,EAAE;QACH,cAAc,EAAE,GAAG;QACnB,UAAU,EAAE,SAAS;QACrB,gBAAgB,EAAE,sBAAsB;QACxC,eAAe,EAAE,IAAI;QACrB,iBAAiB,EAAE,IAAI;QACvB,oBAAoB,EAAE,KAAK;QAC3B,UAAU,EAAE,KAAK;KACpB;CACJ,CAAA","sourcesContent":["import type { FinalConfig } from '../../types.js'\n\nexport const defaultConfig: FinalConfig = {\n testsBase: '.',\n tests: [\n '**/*.sxyt.{js,mjs,jsx}',\n '**/*.test.{js,mjs,jsx}',\n '**/*.spec.{js,mjs,jsx}',\n '**/tests?/*.{js,mjs,jsx}',\n '**/__tests?__/*.{js,mjs,jsx}'\n ],\n testsIgnore: ['**/node_modules/**/*'],\n showErrorTrace: false,\n compact: false,\n execution: {\n files: 'sequential',\n describes: 'sequential',\n tests: 'sequential'\n },\n watch: {\n watchFilesBase: '.',\n watchFiles: '**/*.js',\n watchFilesIgnore: '**/node_modules/**/*',\n runAllOnStartup: true,\n reRunFailingTests: true,\n ttyActionsOnKeypress: false,\n statusFile: false\n }\n}\n"]}
@@ -4,13 +4,17 @@ export async function doUserSetup(config) {
4
4
  if (config.setup === undefined)
5
5
  return;
6
6
  const setupTasks = Array.isArray(config.setup) ? config.setup : [config.setup];
7
+ let setupFunctions = 0;
8
+ let setupFiles = 0;
7
9
  for (const setupTask of setupTasks) {
8
10
  switch (typeof setupTask) {
9
11
  case 'function': {
12
+ out('Running setup function ' + String(++setupFunctions));
10
13
  await setupTask();
11
14
  break;
12
15
  }
13
16
  case 'string': {
17
+ out('Running setup file ' + String(++setupFiles) + ': ' + setupTask);
14
18
  await import(`file://${join(process.cwd(), setupTask)}`);
15
19
  break;
16
20
  }
@@ -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,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACjC,QAAQ,OAAO,SAAS,EAAE,CAAC;YACvB,KAAK,UAAU,CAAC,CAAC,CAAC;gBACd,MAAM,SAAS,EAAE,CAAA;gBACjB,MAAK;YACT,CAAC;YACD,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACZ,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 for (const setupTask of setupTasks) {\n switch (typeof setupTask) {\n case 'function': {\n await setupTask()\n break\n }\n case 'string': {\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,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"]}
@@ -0,0 +1,3 @@
1
+ import type { TestFile, TestResult } from '../../types.js';
2
+ export declare function failureLines(testResults: TestResult[], erroringTests?: Record<string, TestFile>): string[];
3
+ //# sourceMappingURL=failureLines.d.ts.map
@@ -0,0 +1,43 @@
1
+ // The failures for the status file, as f: file > d: describe > t: test > error. Errors are
2
+ // reduced to a single line - anything wanting the diff, the logs or the trace reads the
3
+ // terminal.
4
+ export function failureLines(testResults, erroringTests = {}) {
5
+ const lines = [];
6
+ for (const [file, test] of Object.entries(erroringTests)) {
7
+ lines.push(` f: ${file}`, ` e: did not load: ${simplifyError(test.error)}`);
8
+ }
9
+ for (const testResult of testResults) {
10
+ const fileLines = [];
11
+ for (const describeResult of testResult.describeResults) {
12
+ const describeLines = [];
13
+ if (describeResult.error !== undefined) {
14
+ describeLines.push(` e: threw: ${simplifyError(describeResult.error)}`);
15
+ }
16
+ for (const itResult of describeResult.itResults) {
17
+ if (itResult.success !== false)
18
+ continue;
19
+ describeLines.push(` t: ${itResult.should}`, ` e: ${simplifyError(itResult.error)}`);
20
+ }
21
+ if (describeLines.length > 0) {
22
+ fileLines.push(` d: ${describeResult.thing}`, ...describeLines);
23
+ }
24
+ }
25
+ if (fileLines.length > 0)
26
+ lines.push(` f: ${testResult.file}`, ...fileLines);
27
+ }
28
+ return (lines.length > 0) ? ['Failures:', ...lines] : [];
29
+ }
30
+ function simplifyError(error) {
31
+ if (error === undefined || error === null || error === false)
32
+ return 'unknown error';
33
+ if (typeof error === 'object' && 'message' in error && typeof error.message === 'string') {
34
+ const name = ('name' in error && typeof error.name === 'string') ? error.name : 'Error';
35
+ return `${name}: ${firstLine(error.message)}`;
36
+ }
37
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string -- only a fallback
38
+ return firstLine(String(error));
39
+ }
40
+ function firstLine(text) {
41
+ return text.split('\n')[0]?.trim() ?? '';
42
+ }
43
+ //# sourceMappingURL=failureLines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failureLines.js","sourceRoot":"","sources":["../../../src/cli/lib/failureLines.ts"],"names":[],"mappings":"AAEA,2FAA2F;AAC3F,wFAAwF;AACxF,YAAY;AACZ,MAAM,UAAU,YAAY,CACxB,WAAyB,EACzB,gBAA0C,EAAE;IAE5C,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;QACvD,KAAK,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,wBAAwB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACnF,CAAC;IAED,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,MAAM,SAAS,GAAa,EAAE,CAAA;QAE9B,KAAK,MAAM,cAAc,IAAI,UAAU,CAAC,eAAe,EAAE,CAAC;YACtD,MAAM,aAAa,GAAa,EAAE,CAAA;YAElC,IAAI,c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AC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAA;QACvF,OAAO,GAAG,IAAI,KAAK,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAA;IACjD,CAAC;IAED,mFAAmF;IACnF,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AACnC,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AAC5C,CAAC","sourcesContent":["import type { TestFile, TestResult } from '../../types.js'\n\n// The failures for the status file, as f: file > d: describe > t: test > error. Errors are\n// reduced to a single line - anything wanting the diff, the logs or the trace reads the\n// terminal.\nexport function failureLines(\n testResults: TestResult[],\n erroringTests: Record<string, TestFile> = {}\n): string[] {\n const lines: string[] = []\n\n for (const [file, test] of Object.entries(erroringTests)) {\n lines.push(` f: ${file}`, ` e: did not load: ${simplifyError(test.error)}`)\n }\n\n for (const testResult of testResults) {\n const fileLines: string[] = []\n\n for (const describeResult of testResult.describeResults) {\n const describeLines: string[] = []\n\n if (describeResult.error !== undefined) {\n describeLines.push(` e: threw: ${simplifyError(describeResult.error)}`)\n }\n\n for (const itResult of describeResult.itResults) {\n if (itResult.success !== false) continue\n describeLines.push(\n ` t: ${itResult.should}`,\n ` e: ${simplifyError(itResult.error)}`\n )\n }\n\n if (describeLines.length > 0) {\n fileLines.push(` d: ${describeResult.thing}`, ...describeLines)\n }\n }\n\n if (fileLines.length > 0) lines.push(` f: ${testResult.file}`, ...fileLines)\n }\n\n return (lines.length > 0) ? ['Failures:', ...lines] : []\n}\n\nfunction simplifyError(error: unknown): string {\n if (error === undefined || error === null || error === false) return 'unknown error'\n\n if (typeof error === 'object' && 'message' in error && typeof error.message === 'string') {\n const name = ('name' in error && typeof error.name === 'string') ? error.name : 'Error'\n return `${name}: ${firstLine(error.message)}`\n }\n\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- only a fallback\n return firstLine(String(error))\n}\n\nfunction firstLine(text: string): string {\n return text.split('\\n')[0]?.trim() ?? ''\n}\n"]}
@@ -9,14 +9,26 @@ import { loadTestFile } from './loadTestFile.js';
9
9
  import { runTest } from './runTest.js';
10
10
  import { showTestLoadingError } from './showTestLoadingError.js';
11
11
  import { showTestResult } from './showTestResult.js';
12
+ import { failureLines } from './failureLines.js';
13
+ import { statusCodes, writeStatusFile } from './statusFile.js';
12
14
  import { makeRunManagerState } from './makeWatchRunState.js';
13
15
  const { timeProfileAsync } = createTimeProfiler(showTimeProfiling);
16
+ // the summary lines, minus the colouring, for the status file
17
+ function joinPlain(...parts) {
18
+ return parts.filter(part => part !== '').join(' ');
19
+ }
20
+ function plural(count, noun, verb) {
21
+ if (count < 1)
22
+ return '';
23
+ return `${count} ${noun}${count === 1 ? '' : 's'} ${verb}`;
24
+ }
14
25
  export async function runTests(config, testFiles, reRunManager, refresh = 'refresh', customOut, filters = {}) {
15
26
  if (reRunManager !== undefined) {
16
27
  reRunManager.state.lastTestFiles = new Set(testFiles);
17
28
  reRunManager.state.activeRuns++; // whatever, obsolete. Can use it to check on things
18
29
  }
19
30
  const state = reRunManager?.state || makeRunManagerState();
31
+ const runStartTime = new Date().getTime();
20
32
  //console.log('new runTests:', watchRunState?.activeRuns)
21
33
  //console.log(inspect(testFiles))
22
34
  try {
@@ -99,6 +111,7 @@ export async function runTests(config, testFiles, reRunManager, refresh = 'refre
99
111
  && failedToLoadCount === 0
100
112
  && describesThrownCount === 0) {
101
113
  out(chalk.orange('No tests matched the describe/test filters.'));
114
+ writeStatusFile(config, statusCodes.couldNotRun, 'no tests matched the describe/test filters', [], new Date().getTime() - runStartTime);
102
115
  return null;
103
116
  }
104
117
  out('\n');
@@ -121,17 +134,19 @@ export async function runTests(config, testFiles, reRunManager, refresh = 'refre
121
134
  }
122
135
  // number of items successful
123
136
  const describesText = `Items: ${testsResultsSummary.describesPasses}/${testsResultsSummary.describesTotal}`;
124
- const invalidDescribesText = (testsResultsSummary.describesInvalid >= 1)
137
+ const invalidDescribesPlain = (testsResultsSummary.describesInvalid >= 1)
125
138
  ? (testsResultsSummary.describesInvalid === 1)
126
- ? chalk.grey('(+1 describe without tests)')
127
- : chalk.grey(`(+${testsResultsSummary.describesInvalid} describes without tests)`)
139
+ ? '(+1 describe without tests)'
140
+ : `(+${testsResultsSummary.describesInvalid} describes without tests)`
128
141
  : '';
129
- const describesThrownText = (describesThrownCount >= 1)
142
+ const describesThrownPlain = (describesThrownCount >= 1)
130
143
  ? (describesThrownCount === 1)
131
- ? chalk.mediumred('(1 describe errored)')
132
- : chalk.mediumred(`(${describesThrownCount} describes errored)`)
144
+ ? '(1 describe errored)'
145
+ : `(${describesThrownCount} describes errored)`
133
146
  : '';
134
- const describesDetailsText = [invalidDescribesText, describesThrownText]
147
+ const describesDetailsText = [
148
+ chalk.grey(invalidDescribesPlain), chalk.mediumred(describesThrownPlain)
149
+ ]
135
150
  .filter(text => text !== '')
136
151
  .join(' ');
137
152
  const describesDetailsSuffix = describesDetailsText === '' ? '' : ` ${describesDetailsText}`;
@@ -143,17 +158,19 @@ export async function runTests(config, testFiles, reRunManager, refresh = 'refre
143
158
  }
144
159
  // number of test files successful
145
160
  const testFilesText = `Test Files: ${testsResultsSummary.passes}/${testsResultsSummary.total}`;
146
- const invalidTestFilesText = (testsResultsSummary.invalid >= 1)
161
+ const invalidTestFilesPlain = (testsResultsSummary.invalid >= 1)
147
162
  ? (testsResultsSummary.invalid === 1)
148
- ? chalk.grey('(+1 file without tests)')
149
- : chalk.grey(`(+${testsResultsSummary.invalid} files without tests)`)
163
+ ? '(+1 file without tests)'
164
+ : `(+${testsResultsSummary.invalid} files without tests)`
150
165
  : '';
151
- const failedToLoadText = (failedToLoadCount >= 1)
166
+ const failedToLoadPlain = (failedToLoadCount >= 1)
152
167
  ? (failedToLoadCount === 1)
153
- ? chalk.mediumred('(1 file failed to load, or errored)')
154
- : chalk.mediumred(`(${failedToLoadCount} files failed to load, or errored)`)
168
+ ? '(1 file failed to load, or errored)'
169
+ : `(${failedToLoadCount} files failed to load, or errored)`
155
170
  : '';
156
- const testFilesDetailsText = [invalidTestFilesText, failedToLoadText]
171
+ const testFilesDetailsText = [
172
+ chalk.grey(invalidTestFilesPlain), chalk.mediumred(failedToLoadPlain)
173
+ ]
157
174
  .filter(text => text !== '')
158
175
  .join(' ');
159
176
  const testFilesDetailsSuffix = testFilesDetailsText === '' ? '' : ` ${testFilesDetailsText}`;
@@ -163,6 +180,31 @@ export async function runTests(config, testFiles, reRunManager, refresh = 'refre
163
180
  else {
164
181
  out(chalk.mediumred(`${testFilesText}`) + testFilesDetailsSuffix);
165
182
  }
183
+ const summaryLines = [
184
+ testsText,
185
+ joinPlain(describesText, invalidDescribesPlain, describesThrownPlain),
186
+ joinPlain(testFilesText, invalidTestFilesPlain, failedToLoadPlain)
187
+ ];
188
+ const durationMs = new Date().getTime() - runStartTime;
189
+ if (allPassed) {
190
+ writeStatusFile(config, statusCodes.passed, 'all tests passed', summaryLines, durationMs);
191
+ }
192
+ else {
193
+ const abortedFiles = Object.keys(erroringTests);
194
+ // a file that would not load, or a describe that threw, means the run died
195
+ // partway - a different problem from tests that ran and failed
196
+ const aborted = abortedFiles.length > 0 || describesThrownCount > 0;
197
+ const failedTestsCount = testsResultsSummary.itsTotal - testsResultsSummary.itsPasses;
198
+ const description = [
199
+ plural(abortedFiles.length, 'test file', 'failed to load or errored'),
200
+ plural(describesThrownCount, 'describe', 'errored'),
201
+ plural(failedTestsCount, 'test', 'failed')
202
+ ].filter(part => part !== '').join(', ') || 'test run failed';
203
+ writeStatusFile(config, (aborted) ? statusCodes.aborted : statusCodes.failed, description, [
204
+ ...summaryLines,
205
+ ...failureLines(Object.values(runTestResults), erroringTests)
206
+ ], durationMs);
207
+ }
166
208
  // full success?
167
209
  // true/false gets returned to the caller of runTests()
168
210
  return allPassed;
@@ -1 +1 @@
1
- {"version":3,"file":"runT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,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,mBAAmB,CAAC,OAAO,uBAAuB,CAAC;gBACzE,CAAC,CAAC,EAAE,CAAA;YACR,MAAM,gBAAgB,GAAG,CAAC,iBAAiB,IAAI,CAAC,CAAC;gBAC7C,CAAC,CAAC,CAAC,iBAAiB,KAAK,CAAC,CAAC;oBACvB,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,qCAAqC,CAAC;oBACxD,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,iBAAiB,oCAAoC,CAAC;gBAChF,CAAC,CAAC,EAAE,CAAA;YACR,MAAM,oBAAoB,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC;iBAChE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;iBAC3B,IAAI,CAAC,GAAG,CAAC,CAAA;YACd,MAAM,sBAAsB,GAAG,oBAAoB,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,oBAAoB,EAAE,CAAA;YAC5F,IAAI,mBAAmB,CAAC,MAAM,KAAK,mBAAmB,CAAC,KAAK,EAAE,CAAC;gBAC3D,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,aAAa,EAAE,CAAC,GAAG,sBAAsB,CAAC,CAAA;YACvE,CAAC;iBAAM,CAAC;gBACJ,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,aAAa,EAAE,CAAC,GAAG,sBAAsB,CAAC,CAAA;YACrE,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'\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\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 //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 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 invalidDescribesText = (testsResultsSummary.describesInvalid >= 1)\n ? (testsResultsSummary.describesInvalid === 1)\n ? chalk.grey('(+1 describe without tests)')\n : chalk.grey(`(+${testsResultsSummary.describesInvalid} describes without tests)`)\n : ''\n const describesThrownText = (describesThrownCount >= 1)\n ? (describesThrownCount === 1)\n ? chalk.mediumred('(1 describe errored)')\n : chalk.mediumred(`(${describesThrownCount} describes errored)`)\n : ''\n const describesDetailsText = [invalidDescribesText, describesThrownText]\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 invalidTestFilesText = (testsResultsSummary.invalid >= 1)\n ? (testsResultsSummary.invalid === 1)\n ? chalk.grey('(+1 file without tests)')\n : chalk.grey(`(+${testsResultsSummary.invalid} files without tests)`)\n : ''\n const failedToLoadText = (failedToLoadCount >= 1)\n ? (failedToLoadCount === 1)\n ? chalk.mediumred('(1 file failed to load, or errored)')\n : chalk.mediumred(`(${failedToLoadCount} files failed to load, or errored)`)\n : ''\n const testFilesDetailsText = [invalidTestFilesText, failedToLoadText]\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 // 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,WAAW,EAAE,eAAe,EAAE,MAAM,i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U,CAC3E,CAAA;YACL,CAAC;iBAAM,CAAC;gBACJ,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;gBAE/C,2EAA2E;gBAC3E,+DAA+D;gBAC/D,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,oBAAoB,GAAG,CAAC,CAAA;gBACnE,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,QAAQ,GAAG,mBAAmB,CAAC,SAAS,CAAA;gBAErF,MAAM,WAAW,GAAG;oBAChB,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,2BAA2B,CAAC;oBACrE,MAAM,CAAC,oBAAoB,EAAE,UAAU,EAAE,SAAS,CAAC;oBACnD,MAAM,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,CAAA;gBAE7D,eAAe,CACX,MAAM,EACN,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,EACpD,WAAW,EACX;oBACI,GAAG,YAAY;oBACf,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC;iBAChE,EACD,UAAU,CACb,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 { 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 //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 writeStatusFile(\n config,\n statusCodes.couldNotRun,\n 'no tests matched the describe/test filters',\n [],\n new Date().getTime() - runStartTime\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 } 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 writeStatusFile(\n config,\n (aborted) ? statusCodes.aborted : statusCodes.failed,\n description,\n [\n ...summaryLines,\n ...failureLines(Object.values(runTestResults), erroringTests)\n ],\n durationMs\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,12 @@
1
+ import type { FinalConfig } from '../../types.js';
2
+ export declare const statusCodes: {
3
+ readonly notRunYet: -1;
4
+ readonly passed: 0;
5
+ readonly failed: 1;
6
+ readonly aborted: 2;
7
+ readonly couldNotRun: 3;
8
+ };
9
+ export type StatusCode = typeof statusCodes[keyof typeof statusCodes];
10
+ export declare function resetStatusFile(config: FinalConfig): void;
11
+ export declare function writeStatusFile(config: FinalConfig, code: StatusCode, description: string, details?: string[], durationMs?: number): void;
12
+ //# sourceMappingURL=statusFile.d.ts.map
@@ -0,0 +1,60 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import chalk from '../../packages/chalk.js';
4
+ import { packageName } from '../../config.js';
5
+ import { log } from '../../output.js';
6
+ // The status file holds the result of the latest run: `<code> - <description>` on the first
7
+ // line, then any detail. Watch mode resets it to -1 on startup so a stale result is never
8
+ // mistaken for the current one.
9
+ export const statusCodes = {
10
+ notRunYet: -1, // watch mode has started, but no run has finished
11
+ passed: 0,
12
+ failed: 1, // tests ran and failed
13
+ aborted: 2, // the run died partway - a test file failed to load, or a describe threw
14
+ couldNotRun: 3 // nothing ran at all - no test files, or no match for the filters
15
+ };
16
+ export function resetStatusFile(config) {
17
+ writeStatusFile(config, statusCodes.notRunYet, 'no run has finished yet');
18
+ }
19
+ export function writeStatusFile(config, code, description, details = [], durationMs) {
20
+ write(config, [
21
+ `${code} - ${description}`,
22
+ localTime(new Date()),
23
+ ...details,
24
+ ...(durationMs === undefined) ? [] : [`${durationMs.toLocaleString()}ms`]
25
+ ].join('\n') + '\n');
26
+ }
27
+ // local time, so the file reads the way the terminal beside it does, with the offset so a
28
+ // reader elsewhere can still place it
29
+ function localTime(date) {
30
+ const pad = (value) => String(value).padStart(2, '0');
31
+ // getTimezoneOffset() counts minutes behind UTC, so the sign is the other way round
32
+ const offsetMinutes = -date.getTimezoneOffset();
33
+ const offset = `${(offsetMinutes < 0) ? '-' : '+'}`
34
+ + `${pad(Math.floor(Math.abs(offsetMinutes) / 60))}:${pad(Math.abs(offsetMinutes) % 60)}`;
35
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
36
+ + ` ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
37
+ + ` ${offset}`;
38
+ }
39
+ function write(config, contents) {
40
+ const statusFile = config.watch.statusFile;
41
+ if (typeof statusFile !== 'string' || statusFile === '')
42
+ return;
43
+ const location = path.resolve(process.cwd(), statusFile);
44
+ // written via a temp file and renamed, so a poller never reads a half written status
45
+ const tempLocation = `${location}.${process.pid}.tmp`;
46
+ try {
47
+ fs.mkdirSync(path.dirname(location), { recursive: true });
48
+ fs.writeFileSync(tempLocation, contents);
49
+ fs.renameSync(tempLocation, location);
50
+ }
51
+ catch (error) {
52
+ // never let the status file take the run down with it
53
+ log(chalk.mediumred(`[${packageName}] Could not write status file ${location}: ${String(error)}`));
54
+ try {
55
+ fs.rmSync(tempLocation, { force: true });
56
+ }
57
+ catch { /* nothing more to do */ }
58
+ }
59
+ }
60
+ //# sourceMappingURL=statusFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusFile.js","sourceRoot":"","sources":["../../../src/cli/lib/statusFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAIrC,4FAA4F;AAC5F,0FAA0F;AAC1F,gCAAgC;AAChC,MAAM,CAAC,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KAAK,CAAC,EAAE,CAC/E,CAAC,CAAA;QACF,IAAI,CAAC;YAAC,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,wBAAwB,CAAC,CAAC;IACvF,CAAC;AACL,CAAC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\n\nimport chalk from '../../packages/chalk.js'\nimport { packageName } from '../../config.js'\nimport { log } from '../../output.js'\n\nimport type { FinalConfig } from '../../types.js'\n\n// The status file holds the result of the latest run: `<code> - <description>` on the first\n// line, then any detail. Watch mode resets it to -1 on startup so a stale result is never\n// mistaken for the current one.\nexport const statusCodes = {\n notRunYet: -1, // watch mode has started, but no run has finished\n passed: 0,\n failed: 1, // tests ran and failed\n aborted: 2, // the run died partway - a test file failed to load, or a describe threw\n couldNotRun: 3 // nothing ran at all - no test files, or no match for the filters\n} as const\n\nexport type StatusCode = typeof statusCodes[keyof typeof statusCodes]\n\nexport function resetStatusFile(config: FinalConfig): void {\n writeStatusFile(config, statusCodes.notRunYet, 'no run has finished yet')\n}\n\nexport function writeStatusFile(\n config: FinalConfig,\n code: StatusCode,\n description: string,\n details: string[] = [],\n durationMs?: number\n): void {\n write(config, [\n `${code} - ${description}`,\n localTime(new Date()),\n ...details,\n ...(durationMs === undefined) ? [] : [`${durationMs.toLocaleString()}ms`]\n ].join('\\n') + '\\n')\n}\n\n// local time, so the file reads the way the terminal beside it does, with the offset so a\n// reader elsewhere can still place it\nfunction localTime(date: Date): string {\n const pad = (value: number): string => String(value).padStart(2, '0')\n // getTimezoneOffset() counts minutes behind UTC, so the sign is the other way round\n const offsetMinutes = -date.getTimezoneOffset()\n const offset = `${(offsetMinutes < 0) ? '-' : '+'}`\n + `${pad(Math.floor(Math.abs(offsetMinutes) / 60))}:${pad(Math.abs(offsetMinutes) % 60)}`\n return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`\n + ` ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`\n + ` ${offset}`\n}\n\nfunction write(config: FinalConfig, contents: string): void {\n const statusFile = config.watch.statusFile\n if (typeof statusFile !== 'string' || statusFile === '') return\n\n const location = path.resolve(process.cwd(), statusFile)\n // written via a temp file and renamed, so a poller never reads a half written status\n const tempLocation = `${location}.${process.pid}.tmp`\n try {\n fs.mkdirSync(path.dirname(location), { recursive: true })\n fs.writeFileSync(tempLocation, contents)\n fs.renameSync(tempLocation, location)\n } catch (error) {\n // never let the status file take the run down with it\n log(chalk.mediumred(\n `[${packageName}] Could not write status file ${location}: ${String(error)}`\n ))\n try { fs.rmSync(tempLocation, { force: true }) } catch { /* nothing more to do */ }\n }\n}\n"]}
@@ -20,5 +20,9 @@ export function validateConfig(config, customOut) {
20
20
  if (typeof config.watch.ttyActionsOnKeypress !== 'boolean') {
21
21
  doError('Config error, config.watch.ttyActionsOnKeypress should be a boolean');
22
22
  }
23
+ const statusFile = config.watch.statusFile;
24
+ if (statusFile !== false && (typeof statusFile !== 'string' || statusFile === '')) {
25
+ doError('Config error, config.watch.statusFile should be false or a file path');
26
+ }
23
27
  }
24
28
  //# sourceMappingURL=validateConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateConfig.js","sourceRoot":"","sources":["../../../src/cli/lib/validateConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAGhD,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,SAAiB;IACjE,MAAM,GAAG,GAAG,SAAS,IAAI,OAAO,CAAA;IAEhC,SAAS,OAAO,CAAC,OAAe;QAC5B,GAAG,CAAC,OAAO,CAAC,CAAA;QACZ,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,+CAA+C,CAAC,CAAA;IAC5D,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QACnF,OAAO,CAAC,+EAA+E,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;QAC3F,OAAO,CAAC,mFAAmF,CAAC,CAAA;IAChG,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;QACnF,OAAO,CAAC,+EAA+E,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,CAAC,qEAAqE,CAAC,CAAA;IAClF,CAAC;AACL,CAAC","sourcesContent":["import { out as mainOut } from '../../output.js'\nimport type { FinalConfig, OutFn } from '../../types.js'\n\nexport function validateConfig(config: FinalConfig, customOut?: OutFn): void {\n const out = customOut ?? mainOut\n\n function doError(message: string): never {\n out(message)\n throw new Error(message)\n }\n\n if (config.execution === undefined) {\n doError('Config error, config.execution is not defined')\n }\n\n if (config.execution.files !== 'parallel' && config.execution.files !== 'sequential') {\n doError('Config error, config.execution.files should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.describes !== 'parallel' && config.execution.describes !== 'sequential') {\n doError('Config error, config.execution.describes should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.tests !== 'parallel' && config.execution.tests !== 'sequential') {\n doError('Config error, config.execution.tests should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (typeof config.watch.ttyActionsOnKeypress !== 'boolean') {\n doError('Config error, config.watch.ttyActionsOnKeypress should be a boolean')\n }\n}\n"]}
1
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,KAAK,EAAE,CAAC,EAAE,CAAC;QAChF,OAAO,CAAC,sEAAsE,CAAC,CAAA;IACnF,CAAC;AACL,CAAC","sourcesContent":["import { out as mainOut } from '../../output.js'\nimport type { FinalConfig, OutFn } from '../../types.js'\n\nexport function validateConfig(config: FinalConfig, customOut?: OutFn): void {\n const out = customOut ?? mainOut\n\n function doError(message: string): never {\n out(message)\n throw new Error(message)\n }\n\n if (config.execution === undefined) {\n doError('Config error, config.execution is not defined')\n }\n\n if (config.execution.files !== 'parallel' && config.execution.files !== 'sequential') {\n doError('Config error, config.execution.files should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.describes !== 'parallel' && config.execution.describes !== 'sequential') {\n doError('Config error, config.execution.describes should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (config.execution.tests !== 'parallel' && config.execution.tests !== 'sequential') {\n doError('Config error, config.execution.tests should be \\'parallel\\' or \\'sequential\\'')\n }\n\n if (typeof config.watch.ttyActionsOnKeypress !== 'boolean') {\n doError('Config error, config.watch.ttyActionsOnKeypress should be a boolean')\n }\n\n const statusFile = config.watch.statusFile\n if (statusFile !== false && (typeof statusFile !== 'string' || statusFile === '')) {\n doError('Config error, config.watch.statusFile should be false or a file path')\n }\n}\n"]}
package/dist/cli/watch.js CHANGED
@@ -31,6 +31,10 @@ export async function watch() {
31
31
  'filter-describe': {
32
32
  flag: 'd',
33
33
  hasValue: true
34
+ },
35
+ 'status-file': {
36
+ flag: 's',
37
+ hasValue: true
34
38
  }
35
39
  };
36
40
  const clArguments = parseCommandLineArguments(allowedClArguments);
@@ -54,6 +58,13 @@ export async function watch() {
54
58
  }
55
59
  userConfig.testsFilter = filter;
56
60
  }
61
+ if ('status-file' in clArguments) {
62
+ const statusFile = clArguments['status-file'];
63
+ if (typeof statusFile !== 'string' || statusFile === '') {
64
+ throw new Error('No file path specified for --status-file or -s argument');
65
+ }
66
+ userConfig.watch = { ...userConfig.watch, statusFile };
67
+ }
57
68
  const filterIt = clArguments['filter-it'];
58
69
  const filterDescribe = clArguments['filter-describe'];
59
70
  if (filterIt === true || filterIt === '')
@@ -66,6 +77,9 @@ export async function watch() {
66
77
  const config = applyConfigDefaults(userConfig);
67
78
  const { validateConfig } = await import('./lib/validateConfig.js');
68
79
  validateConfig(config);
80
+ // no run has finished yet, so the status file starts at -1 rather than stale
81
+ const { resetStatusFile, statusCodes, writeStatusFile } = await import('./lib/statusFile.js');
82
+ resetStatusFile(config);
69
83
  const { doUserSetup } = await import('./lib/doUserSetup.js');
70
84
  await doUserSetup(config);
71
85
  // watch mode never reaches an end of its own, so teardown only gets a chance on the way
@@ -110,6 +124,7 @@ export async function watch() {
110
124
  }
111
125
  else {
112
126
  out(chalk.orange `no test files found`);
127
+ writeStatusFile(config, statusCodes.couldNotRun, 'no test files found');
113
128
  }
114
129
  const { watchFilesAndRunTests } = await import('./lib/watchFilesAndRunTests.js');
115
130
  await watchFilesAndRunTests(config,
@@ -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,GAAG,CAAC,KAAK,CAAC,UAAU,CAAA,IAAI,WAAW,MAAM,CAAC,CAAA;I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AAE,gBAAgB,CAAC,CAAA;IACxF,CAAC,EACD,MAAM,CAAC,KAAK,CAAC,oBAAoB,EACjC,cAAc,CACjB,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'\r\n\r\nimport { packageName } from '../config.js'\r\nimport { out, debug } from '../output.js'\r\n\r\nimport type { AllowedArguments, DependencyTrees } from '../types.js'\r\nimport { setEnv } from './lib/setEnv.js'\r\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\r\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\r\nimport { isTest } from './lib/isTest.js'\r\nimport { makeRunManagerState } from './lib/makeWatchRunState.js'\r\nimport { makeReRunManager } from './lib/reRunManager.js'\r\n\r\nexport async function watch(): Promise<void> {\r\n out(chalk.brightblue`[${packageName}]...`)\r\n\r\n const startTime = new Date().getTime()\r\n\r\n const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js')\r\n const allowedClArguments: AllowedArguments = {\r\n 'config': {\r\n flag: 'c',\r\n hasValue: true\r\n },\r\n 'test-files': {\r\n flag: 't',\r\n hasValue: true\r\n },\r\n 'filter': {\r\n flag: 'f',\r\n hasValue: true\r\n },\r\n 'filter-it': {\r\n flag: 'i',\r\n hasValue: true\r\n },\r\n 'filter-describe': {\r\n flag: 'd',\r\n hasValue: true\r\n }\r\n }\r\n const clArguments = parseCommandLineArguments(allowedClArguments)\r\n //debug('clArguments', clArguments)\r\n\r\n setEnv()\r\n\r\n const { loadConfig } = await import('./lib/loadConfig.js')\r\n const userConfig = (typeof clArguments.config === 'string')\r\n ? await loadConfig(clArguments.config)\r\n : await loadConfig()\r\n\r\n if ('test-files' in clArguments) {\r\n const testFilesPattern = clArguments['test-files']\r\n if (typeof testFilesPattern !== 'string' || testFilesPattern === '') {\r\n throw new Error('No pattern specified for --test-files or -t argument')\r\n }\r\n userConfig.tests = testFilesPattern\r\n }\r\n\r\n if ('filter' in clArguments) {\r\n const filter = clArguments.filter\r\n if (typeof filter !== 'string' || filter === '') {\r\n throw new Error('No pattern specified for --filter or -f argument')\r\n }\r\n userConfig.testsFilter = filter\r\n }\r\n\r\n const filterIt = clArguments['filter-it']\r\n const filterDescribe = clArguments['filter-describe']\r\n if (filterIt === true || filterIt === '') throw new Error('No substring specified for --filter-it')\r\n if (filterDescribe === true || filterDescribe === '') {\r\n throw new Error('No substring specified for --filter-describe')\r\n }\r\n const executionFilters = { it: filterIt, describe: filterDescribe }\r\n\r\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\r\n const config = applyConfigDefaults(userConfig)\r\n\r\n const { validateConfig } = await import('./lib/validateConfig.js')\r\n validateConfig(config)\r\n\r\n const { doUserSetup } = await import('./lib/doUserSetup.js')\r\n await doUserSetup(config)\r\n\r\n // watch mode never reaches an end of its own, so teardown only gets a chance on the way\r\n // out. Registered here so it pairs with the setup above and covers the initial run too.\r\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\r\n const { registerShutdownHandlers } = await import('./lib/shutdown.js')\r\n registerShutdownHandlers(config, {\r\n teardown: doUserTeardown,\r\n exit: code => process.exit(code)\r\n })\r\n\r\n out(chalk.brightblue(findingTestsMessage(config)))\r\n const { findTestFiles } = await import('./lib/findTestFiles.js')\r\n const testFiles = await findTestFiles(config)\r\n debug(testFiles)\r\n\r\n // global store of the dependencies of tests\r\n let dependencyTrees: DependencyTrees = {}\r\n // store failing tests so we can re-run them.\r\n const failingTests: string[] = []\r\n \r\n const reRunManager = makeReRunManager(\r\n null,\r\n makeRunManagerState({\r\n allTestFiles: testFiles,\r\n lastTestFiles: testFiles\r\n }),\r\n )\r\n\r\n const { runTests } = await import('./lib/runTests.js')\r\n let initialTestRun: Promise<boolean | null> | null = null\r\n\r\n if (testFiles.size > 0) {\r\n out(chalk.brightblue(foundTestsMessage(testFiles.size)))\r\n const { buildDependencyTrees } = await import('./lib/buildDependencyTrees.js')\r\n out(chalk.brightblue`finding initial dependency trees...`)\r\n dependencyTrees = await buildDependencyTrees(config, testFiles)\r\n\r\n if (config.watch.runAllOnStartup) {\r\n out(chalk.brightblue`running initial tests...`)\r\n initialTestRun = runTests(\r\n config, testFiles, reRunManager,\r\n (isTest) ? 'refresh' : 'cached',\r\n undefined, executionFilters\r\n ).then(async testsResult => {\r\n const time = new Date().getTime() - startTime\r\n //await new Promise((resolve) => setTimeout(resolve, 100))\r\n out(chalk.grey`\\n${time.toLocaleString()}ms`)\r\n return testsResult\r\n })\r\n reRunManager.state.currentRun = initialTestRun\r\n // do we need to catch errors like this?\r\n initialTestRun.catch(err => `Error during initial test run: ${err}`)\r\n }\r\n } else {\r\n out(chalk.orange`no test files found`)\r\n }\r\n\r\n const { watchFilesAndRunTests } = await import('./lib/watchFilesAndRunTests.js')\r\n await watchFilesAndRunTests(\r\n config,\r\n //testFiles,\r\n dependencyTrees,\r\n failingTests, // CHECK this should also be in state\r\n reRunManager,\r\n //watchRunState,\r\n undefined,\r\n executionFilters\r\n )\r\n\r\n\r\n out(chalk.brightblue`watching...`)\r\n\r\n const { listenToUser } = await import('./lib/listenToUser.js')\r\n listenToUser(\r\n reRunManager,\r\n files => () => {\r\n return runTests(config, files, reRunManager, 'refresh', undefined, executionFilters)\r\n },\r\n config.watch.ttyActionsOnKeypress,\r\n initialTestRun\r\n ).catch(e => { throw e })\r\n\r\n\r\n // park forever - watch mode ends by being signalled, and the shutdown handlers registered\r\n // above run the user's teardown on the way out\r\n await new Promise<void>(() => {})\r\n}\r\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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AAG,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 } 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 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 'status-file': {\n flag: 's',\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 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\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 out(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n debug(testFiles)\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 )\n\n const { runTests } = await import('./lib/runTests.js')\n let initialTestRun: Promise<boolean | null> | null = null\n\n if (testFiles.size > 0) {\n out(chalk.brightblue(foundTestsMessage(testFiles.size)))\n const { buildDependencyTrees } = await import('./lib/buildDependencyTrees.js')\n out(chalk.brightblue`finding initial dependency trees...`)\n dependencyTrees = await buildDependencyTrees(config, testFiles)\n\n if (config.watch.runAllOnStartup) {\n out(chalk.brightblue`running initial tests...`)\n initialTestRun = runTests(\n config, testFiles, reRunManager,\n (isTest) ? 'refresh' : 'cached',\n undefined, executionFilters\n ).then(async testsResult => {\n const time = new Date().getTime() - startTime\n //await new Promise((resolve) => setTimeout(resolve, 100))\n out(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 out(chalk.orange`no test files found`)\n writeStatusFile(config, statusCodes.couldNotRun, 'no test files found')\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 undefined,\n executionFilters\n )\n\n\n out(chalk.brightblue`watching...`)\n\n const { listenToUser } = await import('./lib/listenToUser.js')\n listenToUser(\n reRunManager,\n files => () => {\n return runTests(config, files, reRunManager, 'refresh', undefined, executionFilters)\n },\n config.watch.ttyActionsOnKeypress,\n initialTestRun\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/config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export declare const packageName = "sxy-test-runner";
2
- export declare const cliName = "sxy-test";
2
+ export declare const cliName = "sxyt";
3
3
  export declare const configFileNames: string[];
4
4
  export declare const configLocations: string[];
5
5
  export declare const debugging = false;
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export const packageName = 'sxy-test-runner';
2
- export const cliName = 'sxy-test';
2
+ export const cliName = 'sxyt';
3
3
  export const configFileNames = ['sxyt.config', 'sxy-test-runner.config'];
4
4
  export const configLocations = ['', 'config']; // locations where the configs may be placed in proj folder
5
5
  export const debugging = false;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAA;AAE5C,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAA;AAEjC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,aAAa,EAAE,wBAAwB,CAAC,CAAA;AACxE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA,CAAC,2DAA2D;AAEzG,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAA;AAE9B,6EAA6E;AAC7E,8EAA8E;AAC9E,wDAAwD;AACxD,SAAS,OAAO,CAAC,KAAyB;IACtC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IACrC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;IACzE,OAAO,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,GAAG,CAAA;AACtD,CAAC;AAED,sEAAsE;AACtE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA","sourcesContent":["export const packageName = 'sxy-test-runner'\n\nexport const cliName = 'sxy-test'\n\nexport const configFileNames = ['sxyt.config', 'sxy-test-runner.config']\nexport const configLocations = ['', 'config'] // locations where the configs may be placed in proj folder\n\nexport const debugging = false\n\n// Parse a boolean-ish env var. Accepts true/false and 1/0, case-insensitive,\n// tolerant of surrounding quotes and whitespace (e.g. TIME_PROFILING=\"true\").\n// Anything unrecognised (or unset) is treated as false.\nfunction envFlag(value: string | undefined): boolean {\n if (value === undefined) return false\n const normalized = value.trim().replace(/^[\"']|[\"']$/g, '').toLowerCase()\n return normalized === 'true' || normalized === '1'\n}\n\n// Toggle per-phase timing output with the SXYT_TIME_PROFILING env var\n// (SXYT_TIME_PROFILING=true | 1). Defaults to off so normal runs stay clean.\nexport const showTimeProfiling = envFlag(process.env.SXYT_TIME_PROFILING)\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAA;AAE5C,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAA;AAE7B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,aAAa,EAAE,wBAAwB,CAAC,CAAA;AACxE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA,CAAC,2DAA2D;AAEzG,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAA;AAE9B,6EAA6E;AAC7E,8EAA8E;AAC9E,wDAAwD;AACxD,SAAS,OAAO,CAAC,KAAyB;IACtC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IACrC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;IACzE,OAAO,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,GAAG,CAAA;AACtD,CAAC;AAED,sEAAsE;AACtE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA","sourcesContent":["export const packageName = 'sxy-test-runner'\n\nexport const cliName = 'sxyt'\n\nexport const configFileNames = ['sxyt.config', 'sxy-test-runner.config']\nexport const configLocations = ['', 'config'] // locations where the configs may be placed in proj folder\n\nexport const debugging = false\n\n// Parse a boolean-ish env var. Accepts true/false and 1/0, case-insensitive,\n// tolerant of surrounding quotes and whitespace (e.g. TIME_PROFILING=\"true\").\n// Anything unrecognised (or unset) is treated as false.\nfunction envFlag(value: string | undefined): boolean {\n if (value === undefined) return false\n const normalized = value.trim().replace(/^[\"']|[\"']$/g, '').toLowerCase()\n return normalized === 'true' || normalized === '1'\n}\n\n// Toggle per-phase timing output with the SXYT_TIME_PROFILING env var\n// (SXYT_TIME_PROFILING=true | 1). Defaults to off so normal runs stay clean.\nexport const showTimeProfiling = envFlag(process.env.SXYT_TIME_PROFILING)\n"]}
package/dist/types.d.ts CHANGED
@@ -7,6 +7,7 @@ export interface ExecutionConfig {
7
7
  describes: ExecutionMode;
8
8
  tests: ExecutionMode;
9
9
  }
10
+ export type StatusFileConfig = string | false;
10
11
  export interface WatchConfig {
11
12
  watchFilesBase: string;
12
13
  watchFiles: GlobPattern;
@@ -14,6 +15,7 @@ export interface WatchConfig {
14
15
  runAllOnStartup: boolean;
15
16
  reRunFailingTests: boolean;
16
17
  ttyActionsOnKeypress: boolean;
18
+ statusFile: StatusFileConfig;
17
19
  }
18
20
  export type TaskExports = Record<string, unknown>;
19
21
  export type ConfigTaskFn = (parcel?: TaskExports) => TaskExports | void | Promise<TaskExports | void>;
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,+EAA+E","sourcesContent":["// Shared types for the test-run data model, user config, and CLI plumbing.\n// The config/result shapes are inferred from usage across the old awaitful\n// source (defaultConfig.js, validateConfig.js, init.js's template, and the\n// run*/parseDescribe/showTestResult modules) - there was no prior type source.\n\nimport { DescribeMeta } from './describe.js'\nimport { FileMeta } from './meta.js'\n\nexport type ExecutionMode = 'parallel' | 'sequential'\nexport type GlobPattern = string | string[]\n\nexport interface ExecutionConfig {\n files: ExecutionMode\n describes: ExecutionMode\n tests: ExecutionMode\n}\n\nexport interface WatchConfig {\n watchFilesBase: string\n watchFiles: GlobPattern\n watchFilesIgnore: GlobPattern\n runAllOnStartup: boolean\n reRunFailingTests: boolean\n ttyActionsOnKeypress: boolean\n}\n\nexport type TaskExports = Record<string, unknown>\nexport type ConfigTaskFn = (parcel?: TaskExports) => TaskExports | void | Promise<TaskExports | void>\n// a task may also be a file path (relative to the project root) to dynamically import\nexport type ConfigTask = ConfigTaskFn | string\nexport type ConfigTasks = ConfigTask | ConfigTask[]\n\nexport interface FinalConfig {\n testsBase: string\n tests: GlobPattern\n testsFilter?: string\n testsIgnore: GlobPattern\n setup?: ConfigTasks\n beforeEachFile?: ConfigTasks\n afterEachFile?: ConfigTasks\n beforeEachDescribe?: ConfigTasks\n afterEachDescribe?: ConfigTasks\n beforeEachTest?: ConfigTasks\n afterEachTest?: ConfigTasks\n teardown?: ConfigTasks\n showErrorTrace: boolean\n compact: boolean\n execution: ExecutionConfig\n watch: WatchConfig\n}\n\nexport type UserConfig = Partial<Omit<FinalConfig, 'testsFilter' | 'execution' | 'watch'>> & {\n execution?: Partial<ExecutionConfig>\n watch?: Partial<WatchConfig>\n}\n\nexport type UserConfigInternal = UserConfig & Partial<Pick<FinalConfig, 'testsFilter'>>\n\n\n// -- test-run data model --------------------------------------------------\n\nexport type TestParcel = TaskExports\n\nexport interface DescribeParcel extends TaskExports {\n it: (should: string, test: (parcel: TestParcel) => void | Promise<void>) => void\n test: (should: string, test: (parcel: TestParcel) => void | Promise<void>) => void\n afterDescribe: (func: () => void | Promise<void>) => void\n beforeEachTest: (func: () => TaskExports | void | Promise<TaskExports | void>) => void\n afterEachTest: (func: () => void | Promise<void>) => void\n}\n\nexport type DescribeCallback = (parcel: DescribeParcel) => void | Promise<void>\n\nexport interface Describe {\n counter: number\n thing: string\n meta?: DescribeMeta\n tests: DescribeCallback\n}\n\nexport interface It {\n counter: number\n should: string\n test: (parcel: TestParcel) => void | Promise<void>\n}\n\nexport interface ParsedDescribe {\n its: It[]\n beforeDescribeExports: TaskExports\n afterDescribeFunc?: () => void | Promise<void>\n beforeEachTestFunc?: () => TaskExports | void | Promise<TaskExports | void>\n afterEachTestFunc?: () => void | Promise<void>\n error?: unknown\n}\n\nexport interface TestError extends Error {\n actual?: unknown\n expected?: unknown\n}\n\nexport interface ItResult {\n counter: number\n should: string\n success: boolean | null\n time: number\n error?: TestError\n logs: unknown[][]\n}\n\nexport interface ItResultsSummary {\n total: number\n passes: number\n}\n\nexport interface DescribeResult {\n counter: number\n thing: string\n success: boolean | null\n // total elapsed for the whole describe, filled in by runDescribe once it has finished\n time: number\n itResults: ItResult[]\n itResultsSummary: ItResultsSummary\n logs?: unknown[][]\n error?: unknown\n}\n\nexport interface DescribeResultsSummary {\n total: number\n passes: number\n invalid: number\n itsTotal: number\n itsPasses: number\n}\n\nexport interface TestFile {\n file: string\n describes?: Describe[]\n meta?: FileMeta\n error?: string | false\n logs?: unknown[][]\n}\n\nexport interface TestResult {\n file: string\n success: boolean | null\n describeResults: DescribeResult[]\n describeResultsSummary: DescribeResultsSummary\n logs: unknown[][]\n}\n\nexport interface TestsResultsSummary {\n total: number\n passes: number\n invalid: number\n describesTotal: number\n describesPasses: number\n describesInvalid: number\n itsTotal: number\n itsPasses: number\n}\n\nexport type DependencyTrees = Record<string, string[]>\n\nexport type OutFn = (...texts: unknown[]) => void\n\n\n\n// -- CLI argument parsing ---------------------------------------------------\n\nexport interface AllowedArgument {\n flag?: string\n hasValue: boolean\n}\n\nexport type AllowedArguments = Record<string, AllowedArgument>\nexport type AllowedFlags = Record<string, string>\nexport type ParsedArguments = Record<string, string | true>\n\nexport interface TestExecutionFilters {\n describe?: string\n it?: string\n}\n\n// -- globals ----------------------------------------------------------------\n\nexport interface SxyTestRunnerGlobal {\n describes: Describe[]\n describeCounter: number\n fileMeta?: FileMeta\n}\ndeclare global {\n // eslint-disable-next-line camelcase\n var __sxy_test_runner__: SxyTestRunnerGlobal | undefined\n // eslint-disable-next-line camelcase\n var __sxyt_commandLineArguments: string[]\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,+EAA+E","sourcesContent":["// Shared types for the test-run data model, user config, and CLI plumbing.\n// The config/result shapes are inferred from usage across the old awaitful\n// source (defaultConfig.js, validateConfig.js, init.js's template, and the\n// run*/parseDescribe/showTestResult modules) - there was no prior type source.\n\nimport { DescribeMeta } from './describe.js'\nimport { FileMeta } from './meta.js'\n\nexport type ExecutionMode = 'parallel' | 'sequential'\nexport type GlobPattern = string | string[]\n\nexport interface ExecutionConfig {\n files: ExecutionMode\n describes: ExecutionMode\n tests: ExecutionMode\n}\n\n// path to write the latest watch run status to, or false to write none\nexport type StatusFileConfig = string | false\n\nexport interface WatchConfig {\n watchFilesBase: string\n watchFiles: GlobPattern\n watchFilesIgnore: GlobPattern\n runAllOnStartup: boolean\n reRunFailingTests: boolean\n ttyActionsOnKeypress: boolean\n statusFile: StatusFileConfig\n}\n\nexport type TaskExports = Record<string, unknown>\nexport type ConfigTaskFn = (parcel?: TaskExports) => TaskExports | void | Promise<TaskExports | void>\n// a task may also be a file path (relative to the project root) to dynamically import\nexport type ConfigTask = ConfigTaskFn | string\nexport type ConfigTasks = ConfigTask | ConfigTask[]\n\nexport interface FinalConfig {\n testsBase: string\n tests: GlobPattern\n testsFilter?: string\n testsIgnore: GlobPattern\n setup?: ConfigTasks\n beforeEachFile?: ConfigTasks\n afterEachFile?: ConfigTasks\n beforeEachDescribe?: ConfigTasks\n afterEachDescribe?: ConfigTasks\n beforeEachTest?: ConfigTasks\n afterEachTest?: ConfigTasks\n teardown?: ConfigTasks\n showErrorTrace: boolean\n compact: boolean\n execution: ExecutionConfig\n watch: WatchConfig\n}\n\nexport type UserConfig = Partial<Omit<FinalConfig, 'testsFilter' | 'execution' | 'watch'>> & {\n execution?: Partial<ExecutionConfig>\n watch?: Partial<WatchConfig>\n}\n\nexport type UserConfigInternal = UserConfig & Partial<Pick<FinalConfig, 'testsFilter'>>\n\n\n// -- test-run data model --------------------------------------------------\n\nexport type TestParcel = TaskExports\n\nexport interface DescribeParcel extends TaskExports {\n it: (should: string, test: (parcel: TestParcel) => void | Promise<void>) => void\n test: (should: string, test: (parcel: TestParcel) => void | Promise<void>) => void\n afterDescribe: (func: () => void | Promise<void>) => void\n beforeEachTest: (func: () => TaskExports | void | Promise<TaskExports | void>) => void\n afterEachTest: (func: () => void | Promise<void>) => void\n}\n\nexport type DescribeCallback = (parcel: DescribeParcel) => void | Promise<void>\n\nexport interface Describe {\n counter: number\n thing: string\n meta?: DescribeMeta\n tests: DescribeCallback\n}\n\nexport interface It {\n counter: number\n should: string\n test: (parcel: TestParcel) => void | Promise<void>\n}\n\nexport interface ParsedDescribe {\n its: It[]\n beforeDescribeExports: TaskExports\n afterDescribeFunc?: () => void | Promise<void>\n beforeEachTestFunc?: () => TaskExports | void | Promise<TaskExports | void>\n afterEachTestFunc?: () => void | Promise<void>\n error?: unknown\n}\n\nexport interface TestError extends Error {\n actual?: unknown\n expected?: unknown\n}\n\nexport interface ItResult {\n counter: number\n should: string\n success: boolean | null\n time: number\n error?: TestError\n logs: unknown[][]\n}\n\nexport interface ItResultsSummary {\n total: number\n passes: number\n}\n\nexport interface DescribeResult {\n counter: number\n thing: string\n success: boolean | null\n // total elapsed for the whole describe, filled in by runDescribe once it has finished\n time: number\n itResults: ItResult[]\n itResultsSummary: ItResultsSummary\n logs?: unknown[][]\n error?: unknown\n}\n\nexport interface DescribeResultsSummary {\n total: number\n passes: number\n invalid: number\n itsTotal: number\n itsPasses: number\n}\n\nexport interface TestFile {\n file: string\n describes?: Describe[]\n meta?: FileMeta\n error?: string | false\n logs?: unknown[][]\n}\n\nexport interface TestResult {\n file: string\n success: boolean | null\n describeResults: DescribeResult[]\n describeResultsSummary: DescribeResultsSummary\n logs: unknown[][]\n}\n\nexport interface TestsResultsSummary {\n total: number\n passes: number\n invalid: number\n describesTotal: number\n describesPasses: number\n describesInvalid: number\n itsTotal: number\n itsPasses: number\n}\n\nexport type DependencyTrees = Record<string, string[]>\n\nexport type OutFn = (...texts: unknown[]) => void\n\n\n\n// -- CLI argument parsing ---------------------------------------------------\n\nexport interface AllowedArgument {\n flag?: string\n hasValue: boolean\n}\n\nexport type AllowedArguments = Record<string, AllowedArgument>\nexport type AllowedFlags = Record<string, string>\nexport type ParsedArguments = Record<string, string | true>\n\nexport interface TestExecutionFilters {\n describe?: string\n it?: string\n}\n\n// -- globals ----------------------------------------------------------------\n\nexport interface SxyTestRunnerGlobal {\n describes: Describe[]\n describeCounter: number\n fileMeta?: FileMeta\n}\ndeclare global {\n // eslint-disable-next-line camelcase\n var __sxy_test_runner__: SxyTestRunnerGlobal | undefined\n // eslint-disable-next-line camelcase\n var __sxyt_commandLineArguments: string[]\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sxy-test-runner",
3
- "version": "2.3.19",
3
+ "version": "2.3.20",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/RobertSandiford/sxy-test-runner",
6
6
  "repository": {
package/readme.md CHANGED
@@ -81,7 +81,7 @@ The other config options and fairly well explained in the config. More info on t
81
81
  ```
82
82
  npx sxy-test-runner
83
83
  ```
84
- *sxy-test is an alias for sxy-test-runner and can be used instead*
84
+ *sxyt and sxy-test are aliases for sxy-test-runner and can be used instead*
85
85
 
86
86
  ("npx" can be omitted in package.json scripts)
87
87
 
@@ -122,6 +122,52 @@ large set of files and filtering their describes or tests afterward can therefor
122
122
  slower than filtering files first. Prefer `--filter` when a file glob can select the work
123
123
  you need, and use the name filters for further narrowing within those files.
124
124
 
125
+ To have watch mode record each run's result in a file, use `-s` or `--status-file`, or set
126
+ `watch.statusFile` in the config. This is for anything watching the suite from outside - a
127
+ script, a notifier, an agent - that would otherwise have to read the terminal:
128
+
129
+ ```
130
+ npx sxy-test-runner --status-file .sxyt-status
131
+ ```
132
+
133
+ The first line is a status code, a `-`, and a short description. The second is the time the
134
+ run finished, then the summary, then any failures, and the run's duration last:
135
+
136
+ ```
137
+ 1 - 2 tests failed
138
+ 2026-08-03 20:14:52 +01:00
139
+ Tests: 8/10
140
+ Items: 4/5
141
+ Test Files: 1/2
142
+ Failures:
143
+ f: tests/users.test.js
144
+ d: creating a user
145
+ t: rejects a duplicate email
146
+ e: AssertionError: expected 409 to equal 200
147
+ t: sends a welcome email
148
+ e: Error: connect ECONNREFUSED 127.0.0.1:2525
149
+ 1,204ms
150
+ ```
151
+
152
+ Failures nest as `f:` file, `d:` describe, `t:` test, `e:` error - one line each. Diffs, logs
153
+ and stack traces stay in the terminal.
154
+
155
+ | code | meaning |
156
+ | --- | --- |
157
+ | -1 | watch mode has started, but no run has finished |
158
+ | 0 | everything passed |
159
+ | 1 | tests ran and failed |
160
+ | 2 | the run died partway - a test file would not load, or a describe threw |
161
+ | 3 | nothing ran - no test files were found, or the filters matched nothing |
162
+
163
+ Watch mode writes the `-1` status on startup, so a status left over from a previous session
164
+ is never read as the current one. Each write goes to a temporary file and is renamed into
165
+ place, so a poller only ever sees a complete status.
166
+
167
+ Name the file `.sxys` and the VS Code extension in
168
+ [`vscode-sxyt-status/`](vscode-sxyt-status) will colour it - green when the run passed, red
169
+ where it did not.
170
+
125
171
  To specific an alternate config, use -c or --config
126
172
  ```
127
173
  npx sxy-test-runner --config sxy-test-runner.alternate.config.js