sxy-test-runner 2.4.8 → 2.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/AGENTS.md +20 -3
  2. package/dist/checkMeta.d.ts +2 -0
  3. package/dist/checkMeta.js +14 -0
  4. package/dist/checkMeta.js.map +1 -0
  5. package/dist/cli/init.js +31 -8
  6. package/dist/cli/init.js.map +1 -1
  7. package/dist/cli/lib/alwaysCacheBust.d.ts +2 -0
  8. package/dist/cli/lib/alwaysCacheBust.js +3 -0
  9. package/dist/cli/lib/alwaysCacheBust.js.map +1 -0
  10. package/dist/cli/lib/failureEntries.js +12 -1
  11. package/dist/cli/lib/failureEntries.js.map +1 -1
  12. package/dist/cli/lib/isTest.d.ts +1 -1
  13. package/dist/cli/lib/isTest.js +2 -1
  14. package/dist/cli/lib/isTest.js.map +1 -1
  15. package/dist/cli/lib/parseDescribe.js +26 -6
  16. package/dist/cli/lib/parseDescribe.js.map +1 -1
  17. package/dist/cli/lib/reRunManager.d.ts +1 -1
  18. package/dist/cli/lib/reRunManager.js +1 -0
  19. package/dist/cli/lib/reRunManager.js.map +1 -1
  20. package/dist/cli/lib/runDescribeRun.js +2 -0
  21. package/dist/cli/lib/runDescribeRun.js.map +1 -1
  22. package/dist/cli/lib/runTest.js +2 -0
  23. package/dist/cli/lib/runTest.js.map +1 -1
  24. package/dist/cli/lib/runTests.d.ts +4 -1
  25. package/dist/cli/lib/runTests.js +1 -1
  26. package/dist/cli/lib/runTests.js.map +1 -1
  27. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +1 -1
  28. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js.map +1 -1
  29. package/dist/cli/once.js +5 -2
  30. package/dist/cli/once.js.map +1 -1
  31. package/dist/cli/watch.js +6 -3
  32. package/dist/cli/watch.js.map +1 -1
  33. package/dist/config.js +2 -9
  34. package/dist/config.js.map +1 -1
  35. package/dist/describe.js +2 -0
  36. package/dist/describe.js.map +1 -1
  37. package/dist/envFlag.d.ts +2 -0
  38. package/dist/envFlag.js +14 -0
  39. package/dist/envFlag.js.map +1 -0
  40. package/dist/meta.js +2 -0
  41. package/dist/meta.js.map +1 -1
  42. package/package.json +1 -1
package/AGENTS.md CHANGED
@@ -285,6 +285,9 @@ describe('server', ({ it, beforeEachTest, afterEachTest, afterDescribe }) => {
285
285
  })
286
286
  ```
287
287
 
288
+ A describe callback that throws runs none of its tests, not even those registered before the
289
+ throw. It reports as a describe that threw: `aborted`, exit `20`.
290
+
288
291
  ## Execution and isolation
289
292
 
290
293
  Configuration has `execution.files`, `execution.describes`, and `execution.tests`, each
@@ -295,9 +298,20 @@ uses one process, so globals, environment variables, singleton modules, open por
295
298
  shared databases can collide. Per-test `console.log` association also depends on sequential
296
299
  execution because the runner temporarily replaces the global `console.log`.
297
300
 
298
- Current implementation detail: individual tests inside a describe are awaited one at a
299
- time even when `execution.tests` is set to `parallel`. Do not design a suite that depends
300
- on parallel `it` execution.
301
+ A describe can override `execution.tests` for itself, with a meta argument between the name
302
+ and the callback:
303
+
304
+ ```js
305
+ describe('isolated work', { parallelTests: true }, ({ it }) => { /* ... */ })
306
+ describe('shared fixture', { sequentialTests: true }, ({ it }) => { /* ... */ })
307
+ ```
308
+
309
+ The meta argument is authoritative in both directions, so `{ parallelTests: false }` forces
310
+ sequential even under `execution.tests: 'parallel'`.
311
+
312
+ Implementation detail: test files are always *loaded* one at a time, whatever
313
+ `execution.files` says - only their running overlaps. A file's tests therefore start while
314
+ the next file is still loading.
301
315
 
302
316
  ## Watch mode
303
317
 
@@ -356,6 +370,9 @@ Failures:
356
370
  1,204ms
357
371
  ```
358
372
 
373
+ `Items:` (`items=` in the agent stream) counts describe blocks; `Tests:` counts `it`/`test`
374
+ blocks.
375
+
359
376
  Failures nest as `f:` file, `d:` describe, `t:` test, `e:` error - one line each. A file that
360
377
  would not load gives `e: did not load: <error>` under its `f:` line, and a describe that
361
378
  threw gives `e: threw: <error>` under its `d:` line. Diffs, logs and stack traces are only in
@@ -0,0 +1,2 @@
1
+ export declare function checkMeta(context: string, meta: unknown, keys: readonly string[]): void;
2
+ //# sourceMappingURL=checkMeta.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { inspect } from 'node:util';
2
+ // Test files are .js as often as .ts, so the meta unions catch nothing there: a mistyped key
3
+ // would be stored verbatim and silently flip execution the wrong way. Rejected at the point
4
+ // it is written instead, while the file is loading.
5
+ export function checkMeta(context, meta, keys) {
6
+ const named = (typeof meta === 'object' && meta !== null)
7
+ ? Object.entries(meta).filter(([key, value]) => keys.includes(key) && typeof value === 'boolean')
8
+ : [];
9
+ if (named.length === 1)
10
+ return;
11
+ throw new Error(`${context} was given an invalid meta: expected exactly one of `
12
+ + `${keys.join(' or ')}, with a boolean value. Received ${inspect(meta)}`);
13
+ }
14
+ //# sourceMappingURL=checkMeta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkMeta.js","sourceRoot":"","sources":["../src/checkMeta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,6FAA6F;AAC7F,4FAA4F;AAC5F,oDAAoD;AACpD,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,IAAa,EAAE,IAAuB;IAC7E,MAAM,KAAK,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC;QACrD,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,KAAK,KAAK,SAAS,CAAC;QACjG,CAAC,CAAC,EAAE,CAAA;IAER,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAM;IAE9B,MAAM,IAAI,KAAK,CACX,GAAG,OAAO,sDAAsD;UAC9D,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oCAAoC,OAAO,CAAC,IAAI,CAAC,EAAE,CAC5E,CAAA;AACL,CAAC","sourcesContent":["import { inspect } from 'node:util'\n\n// Test files are .js as often as .ts, so the meta unions catch nothing there: a mistyped key\n// would be stored verbatim and silently flip execution the wrong way. Rejected at the point\n// it is written instead, while the file is loading.\nexport function checkMeta(context: string, meta: unknown, keys: readonly string[]): void {\n const named = (typeof meta === 'object' && meta !== null)\n ? Object.entries(meta).filter(([key, value]) => keys.includes(key) && typeof value === 'boolean')\n : []\n\n if (named.length === 1) return\n\n throw new Error(\n `${context} was given an invalid meta: expected exactly one of `\n + `${keys.join(' or ')}, with a boolean value. Received ${inspect(meta)}`\n )\n}\n"]}
package/dist/cli/init.js CHANGED
@@ -2,6 +2,7 @@ import { join } from 'path';
2
2
  import chalk from '../packages/chalk.js';
3
3
  import { packageName, cliName, configFileNames, configLocations } from '../config.js';
4
4
  import { out } from '../output.js';
5
+ import { exitCodes } from './lib/exitCodes.js';
5
6
  import fs from 'fs';
6
7
  export function init() {
7
8
  const projectDir = process.cwd();
@@ -23,18 +24,25 @@ export function init() {
23
24
  }
24
25
  }
25
26
  function configAlreadyExists(loc) {
26
- out(chalk.orange `[${packageName}] A matching config already exists at ${loc}`
27
+ reportAndExit(`[${packageName}] A matching config already exists at ${loc}`
27
28
  + `\nPlease remove this config before generating a new one with \`${cliName} init\``);
28
29
  }
29
30
  const projectPackageJsonLocation = join(projectDir, 'package.json');
30
31
  if (!fs.existsSync(projectPackageJsonLocation)) {
31
- out(chalk.orange `[${packageName}] No package.json exists in this location`
32
- + '\nPlease initialise the package with `yarn init` on `npm init`'
32
+ reportAndExit(`[${packageName}] No package.json exists in this location`
33
+ + '\nPlease initialise the package with `npm init` or `yarn init`'
33
34
  + ' before running this command, and run this command from the project root folder');
34
35
  }
35
- const packageJsonRaw = fs.readFileSync(projectPackageJsonLocation, 'utf8');
36
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
37
- const packageJson = JSON.parse(packageJsonRaw);
36
+ let packageJson;
37
+ try {
38
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
39
+ packageJson = JSON.parse(fs.readFileSync(projectPackageJsonLocation, 'utf8'));
40
+ }
41
+ catch (error) {
42
+ reportAndExit(`[${packageName}] Could not read the package.json at ${projectPackageJsonLocation}`
43
+ + `\n${error instanceof Error ? error.message : String(error)}`
44
+ + '\nPlease make sure the file is readable and contains valid JSON, then try again');
45
+ }
38
46
  const targetConfigName = (packageJson.type === 'module')
39
47
  // ES6 module
40
48
  ? join(projectDir, configLocations[0] ?? '', configFileNames[0] + '.js')
@@ -43,7 +51,7 @@ export function init() {
43
51
  const defaultConfig = `
44
52
  // @ts-check
45
53
 
46
- /** @satisfies {import('sxy-test-runner').Config} */
54
+ /** @type {import('sxy-test-runner').Config} */
47
55
  export default {
48
56
 
49
57
  // base folder for tests match and ignore patterns
@@ -92,6 +100,9 @@ export default {
92
100
  // tasks to run after each it/test block
93
101
  afterEachTest: undefined,
94
102
 
103
+ // tasks to run once the whole run has finished
104
+ teardown: undefined,
105
+
95
106
  // how to execute the different parts of test files
96
107
  execution: {
97
108
 
@@ -140,7 +151,19 @@ export default {
140
151
  },
141
152
 
142
153
  }`;
143
- fs.writeFileSync(targetConfigName, defaultConfig);
154
+ try {
155
+ fs.writeFileSync(targetConfigName, defaultConfig);
156
+ }
157
+ catch (error) {
158
+ reportAndExit(`[${packageName}] Could not write the config to ${targetConfigName}`
159
+ + `\n${error instanceof Error ? error.message : String(error)}`
160
+ + '\nPlease check the folder is writable, then try again');
161
+ }
144
162
  out(chalk.mediumgreen `[${packageName}] Created config at ` + chalk.blue(targetConfigName));
145
163
  }
164
+ // init cannot continue past any of these, so they report in the error colour and stop
165
+ function reportAndExit(message) {
166
+ out(chalk.mediumred(message));
167
+ process.exit(exitCodes.usageError);
168
+ }
146
169
  //# sourceMappingURL=init.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","source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E,OAAO,SAAS,CAAC,CAAA;IAC7F,CAAC;IAED,MAAM,0BAA0B,GAAG,IAAI,CAAC,UAAU,EAAE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmGE,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\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 // evaluate the dependencies of each test file, and re-run that test file only when they change. \n // Set this to false to re-run everything on any change\n dependencyEvaluation: 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 // report the session as single agent readable lines instead of the usual output\n agent: 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":["../../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AAC,aAAa,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA;IACrD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,aAAa,CAAC,IAAI,WAAW,mCAAmC,gBAAgB,EAAE;cAC5E,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;cAC7D,uDAAuD,CAAC,CAAA;IAClE,CAAC;IAED,GAAG,CAAC,KAAK,CAAC,WAAW,CAAA,IAAI,WAAW,sBAAsB,GAAG,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAC9F,CAAC;AAED,sFAAsF;AACtF,SAAS,aAAa,CAAC,OAAe;IAClC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7B,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;AACtC,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 { exitCodes } from './lib/exitCodes.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): never {\n reportAndExit(`[${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 reportAndExit(`[${packageName}] No package.json exists in this location`\n + '\\nPlease initialise the package with `npm init` or `yarn init`'\n + ' before running this command, and run this command from the project root folder')\n }\n\n let packageJson: { type?: string }\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n packageJson = JSON.parse(fs.readFileSync(projectPackageJsonLocation, 'utf8'))\n } catch (error) {\n reportAndExit(`[${packageName}] Could not read the package.json at ${projectPackageJsonLocation}`\n + `\\n${error instanceof Error ? error.message : String(error)}`\n + '\\nPlease make sure the file is readable and contains valid JSON, then try again')\n }\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/** @type {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\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 // tasks to run once the whole run has finished\n teardown: 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 // evaluate the dependencies of each test file, and re-run that test file only when they change. \n // Set this to false to re-run everything on any change\n dependencyEvaluation: 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 // report the session as single agent readable lines instead of the usual output\n agent: false,\n\n },\n\n}`\n\n try {\n fs.writeFileSync(targetConfigName, defaultConfig)\n } catch (error) {\n reportAndExit(`[${packageName}] Could not write the config to ${targetConfigName}`\n + `\\n${error instanceof Error ? error.message : String(error)}`\n + '\\nPlease check the folder is writable, then try again')\n }\n\n out(chalk.mediumgreen`[${packageName}] Created config at ` + chalk.blue(targetConfigName))\n}\n\n// init cannot continue past any of these, so they report in the error colour and stop\nfunction reportAndExit(message: string): never {\n out(chalk.mediumred(message))\n process.exit(exitCodes.usageError)\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const alwaysCacheBust: boolean;
2
+ //# sourceMappingURL=alwaysCacheBust.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { envFlag } from '../../envFlag.js';
2
+ export const alwaysCacheBust = envFlag(process.env.SXYT_ALWAYS_CACHE_BUST);
3
+ //# sourceMappingURL=alwaysCacheBust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alwaysCacheBust.js","sourceRoot":"","sources":["../../../src/cli/lib/alwaysCacheBust.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA","sourcesContent":["\r\nimport { envFlag } from '../../envFlag.js'\r\n\r\nexport const alwaysCacheBust = envFlag(process.env.SXYT_ALWAYS_CACHE_BUST)\r\n"]}
@@ -2,7 +2,7 @@ import { inspect } from 'node:util';
2
2
  export function failureEntries(testResults, erroringTests = {}) {
3
3
  const entries = [];
4
4
  for (const [file, test] of Object.entries(erroringTests)) {
5
- entries.push({ file, error: `did not load: ${simplifyError(test.error)}` });
5
+ entries.push({ file, error: `did not load: ${loadError(test.error)}` });
6
6
  }
7
7
  for (const testResult of testResults) {
8
8
  for (const describeResult of testResult.describeResults) {
@@ -27,6 +27,17 @@ export function failureEntries(testResults, erroringTests = {}) {
27
27
  }
28
28
  return entries;
29
29
  }
30
+ // the loader stores its own preamble with the real cause on the line below, so the first
31
+ // line alone says only that loading failed - which `did not load` has already said. Drop the
32
+ // preamble and keep the cause, flattened: an import error can run to several lines.
33
+ function loadError(error) {
34
+ if (typeof error !== 'string')
35
+ return simplifyError(error);
36
+ const cause = error.replace(/^Error loading file\r?\n/, '').replace(/\s*[\r\n]+\s*/g, ' ').trim();
37
+ if (cause === '')
38
+ return 'Error loading file';
39
+ return (cause.length > 200) ? `${cause.slice(0, 200)}...` : cause;
40
+ }
30
41
  function simplifyError(error) {
31
42
  if (error === undefined || error === null || error === false)
32
43
  return 'unknown error';
@@ -1 +1 @@
1
- {"version":3,"file":"failureEntries.js","sourceRoot":"","sources":["../../../src/cli/lib/failureEntries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAA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Ac;IAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;SAC3D,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;IACnC,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AAChE,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 { inspect } from 'node:util'\n\nimport type { TestFile, TestResult } from '../../types.js'\n\n// One failure, flattened. `describe` is absent when a file would not load, and `test` is\n// absent when the describe itself threw. Shared by the status file's nested tree and the\n// agent reporter's flat lines, so both describe a failure the same way.\nexport interface FailureEntry {\n file: string\n describe?: string\n test?: string\n error: string\n}\n\nexport function failureEntries(\n testResults: TestResult[],\n erroringTests: Record<string, TestFile> = {}\n): FailureEntry[] {\n const entries: FailureEntry[] = []\n\n for (const [file, test] of Object.entries(erroringTests)) {\n entries.push({ file, error: `did not load: ${simplifyError(test.error)}` })\n }\n\n for (const testResult of testResults) {\n for (const describeResult of testResult.describeResults) {\n if (describeResult.error !== undefined) {\n entries.push({\n file: testResult.file,\n describe: describeResult.thing,\n error: `threw: ${simplifyError(describeResult.error)}`\n })\n }\n\n for (const itResult of describeResult.itResults) {\n if (itResult.success !== false) continue\n entries.push({\n file: testResult.file,\n describe: describeResult.thing,\n test: itResult.should,\n error: simplifyError(itResult.error)\n })\n }\n }\n }\n\n return entries\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)}${comparison(error, 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\n// node:assert's first line is only a preamble - \"Expected values to be strictly equal:\" -\n// with the compared values on the lines below, so the first line alone says nothing about\n// what went wrong. The values are on the error, so put them back. Chai fits its whole\n// message on one line and is left alone.\nfunction comparison(error: object, message: string): string {\n if (!message.includes('\\n')) return ''\n if (!('actual' in error) && !('expected' in error)) return ''\n\n const actual = ('actual' in error) ? summarise(error.actual) : '?'\n const expected = ('expected' in error) ? summarise(error.expected) : '?'\n return ` ${actual} !== ${expected}`\n}\n\n// one line and short: these lines are read in a status file or an agent stream, where a\n// pretty-printed object would swamp everything around it. The terminal still has the full diff.\nfunction summarise(value: unknown): string {\n const text = inspect(value, { depth: 2, breakLength: Infinity })\n .replace(/\\s*[\\r\\n]+\\s*/g, ' ')\n return (text.length > 60) ? `${text.slice(0, 60)}...` : text\n}\n\nfunction firstLine(text: string): string {\n return text.split('\\n')[0]?.trim() ?? ''\n}\n"]}
1
+ {"version":3,"file":"failureEntries.js","sourceRoot":"","sources":["../../../src/cli/lib/failureEntries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAcnC,MAAM,UAAU,cAAc,CAC1B,WAAyB,EACzB,gBAA0C,EAAE;IAE5C,MAAM,OAAO,GAAmB,EAAE,CAAA;IAElC,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;QACvD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,KAAK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AAA;IACxE,OAAO,IAAI,MAAM,QAAQ,QAAQ,EAAE,CAAA;AACvC,CAAC;AAED,wFAAwF;AACxF,gGAAgG;AAChG,SAAS,SAAS,CAAC,KAAc;IAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;SAC3D,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;IACnC,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AAChE,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 { inspect } from 'node:util'\n\nimport type { TestFile, TestResult } from '../../types.js'\n\n// One failure, flattened. `describe` is absent when a file would not load, and `test` is\n// absent when the describe itself threw. Shared by the status file's nested tree and the\n// agent reporter's flat lines, so both describe a failure the same way.\nexport interface FailureEntry {\n file: string\n describe?: string\n test?: string\n error: string\n}\n\nexport function failureEntries(\n testResults: TestResult[],\n erroringTests: Record<string, TestFile> = {}\n): FailureEntry[] {\n const entries: FailureEntry[] = []\n\n for (const [file, test] of Object.entries(erroringTests)) {\n entries.push({ file, error: `did not load: ${loadError(test.error)}` })\n }\n\n for (const testResult of testResults) {\n for (const describeResult of testResult.describeResults) {\n if (describeResult.error !== undefined) {\n entries.push({\n file: testResult.file,\n describe: describeResult.thing,\n error: `threw: ${simplifyError(describeResult.error)}`\n })\n }\n\n for (const itResult of describeResult.itResults) {\n if (itResult.success !== false) continue\n entries.push({\n file: testResult.file,\n describe: describeResult.thing,\n test: itResult.should,\n error: simplifyError(itResult.error)\n })\n }\n }\n }\n\n return entries\n}\n\n// the loader stores its own preamble with the real cause on the line below, so the first\n// line alone says only that loading failed - which `did not load` has already said. Drop the\n// preamble and keep the cause, flattened: an import error can run to several lines.\nfunction loadError(error: unknown): string {\n if (typeof error !== 'string') return simplifyError(error)\n\n const cause = error.replace(/^Error loading file\\r?\\n/, '').replace(/\\s*[\\r\\n]+\\s*/g, ' ').trim()\n if (cause === '') return 'Error loading file'\n return (cause.length > 200) ? `${cause.slice(0, 200)}...` : cause\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)}${comparison(error, 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\n// node:assert's first line is only a preamble - \"Expected values to be strictly equal:\" -\n// with the compared values on the lines below, so the first line alone says nothing about\n// what went wrong. The values are on the error, so put them back. Chai fits its whole\n// message on one line and is left alone.\nfunction comparison(error: object, message: string): string {\n if (!message.includes('\\n')) return ''\n if (!('actual' in error) && !('expected' in error)) return ''\n\n const actual = ('actual' in error) ? summarise(error.actual) : '?'\n const expected = ('expected' in error) ? summarise(error.expected) : '?'\n return ` ${actual} !== ${expected}`\n}\n\n// one line and short: these lines are read in a status file or an agent stream, where a\n// pretty-printed object would swamp everything around it. The terminal still has the full diff.\nfunction summarise(value: unknown): string {\n const text = inspect(value, { depth: 2, breakLength: Infinity })\n .replace(/\\s*[\\r\\n]+\\s*/g, ' ')\n return (text.length > 60) ? `${text.slice(0, 60)}...` : text\n}\n\nfunction firstLine(text: string): string {\n return text.split('\\n')[0]?.trim() ?? ''\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const isTest: boolean;
1
+ export {};
2
2
  //# sourceMappingURL=isTest.d.ts.map
@@ -1,2 +1,3 @@
1
- export const isTest = (process.env.NODE_ENV === 'test');
1
+ export {};
2
+ //export const isTest = (process.env.NODE_ENV === 'test')
2
3
  //# sourceMappingURL=isTest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isTest.js","sourceRoot":"","sources":["../../../src/cli/lib/isTest.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAA","sourcesContent":["\r\n\r\nexport const isTest = (process.env.NODE_ENV === 'test')\r\n"]}
1
+ {"version":3,"file":"isTest.js","sourceRoot":"","sources":["../../../src/cli/lib/isTest.ts"],"names":[],"mappings":";AAEA,yDAAyD","sourcesContent":["\r\n\r\n//export const isTest = (process.env.NODE_ENV === 'test')\r\n"]}
@@ -1,6 +1,20 @@
1
1
  import { timeProfileAsync } from './timeProfier.js';
2
2
  import { runTasks } from './runTasks.js';
3
3
  import { addExports } from './addExports.js';
4
+ class SxytNotAFunctionError extends Error {
5
+ name = 'SxytNotAFunctionError';
6
+ }
7
+ class SxytAlreadyDefinedError extends Error {
8
+ name = 'SxytAlreadyDefinedError';
9
+ }
10
+ function throwMustBeAFunctionError(fname, func) {
11
+ throw new SxytNotAFunctionError(`${fname}() error, argument passed to ${fname}() must be a function,`
12
+ + ` received ${typeof func}`);
13
+ }
14
+ function throwAlreadyDefinedError(fname) {
15
+ throw new SxytAlreadyDefinedError(`${fname}() error, ${fname} function is already defined.`
16
+ + ' Only one function is permitted');
17
+ }
4
18
  export function parseDescribe(config, describe, itFilter) {
5
19
  return timeProfileAsync(`parse its from describe ${describe.thing}`, async () => {
6
20
  let itCounter = 1;
@@ -10,8 +24,10 @@ export function parseDescribe(config, describe, itFilter) {
10
24
  let afterDescribeFunc;
11
25
  function afterDescribe(func) {
12
26
  if (typeof func !== 'function') {
13
- throw new Error('afterDescribe() error, argument passed to afterDescribe() must be a function,'
14
- + ` received ${typeof func}`);
27
+ throwMustBeAFunctionError('afterDescribe', func);
28
+ }
29
+ if (afterDescribeFunc !== undefined) {
30
+ throwAlreadyDefinedError('afterDescribe');
15
31
  }
16
32
  afterDescribeFunc = func;
17
33
  }
@@ -19,8 +35,10 @@ export function parseDescribe(config, describe, itFilter) {
19
35
  let beforeEachTestFunc;
20
36
  function beforeEachTest(func) {
21
37
  if (typeof func !== 'function') {
22
- throw new Error('afterDescribe() error, argument passed to afterDescribe() must be a function,'
23
- + ` received ${typeof func}`);
38
+ throwMustBeAFunctionError('beforeEachTest', func);
39
+ }
40
+ if (beforeEachTestFunc !== undefined) {
41
+ throwAlreadyDefinedError('beforeEachTest');
24
42
  }
25
43
  beforeEachTestFunc = func;
26
44
  }
@@ -28,8 +46,10 @@ export function parseDescribe(config, describe, itFilter) {
28
46
  let afterEachTestFunc;
29
47
  function afterEachTest(func) {
30
48
  if (typeof func !== 'function') {
31
- throw new Error('afterDescribe() error, argument passed to afterDescribe() must be a function,'
32
- + ` received ${typeof func}`);
49
+ throwMustBeAFunctionError('afterEachTest', func);
50
+ }
51
+ if (afterEachTestFunc !== undefined) {
52
+ throwAlreadyDefinedError('afterEachTest');
33
53
  }
34
54
  afterEachTestFunc = func;
35
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parseDescribe.js","sourceRoot":"","sources":["../../../src/cli/lib/parseDescribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI5C,MAAM,UAAU,aAAa,CACzB,MAAmB,EACnB,QAAkB,EAClB,QAAiB;IAEjB,OAAO,gBAAgB,CAAC,2BAA2B,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,IAAI,EAAE;QAC5E,IAAI,SAAS,GAAG,CAAC,CAAA;QACjB,MAAM,GAAG,GAAS,EAAE,CAAA;QAEpB,gCAAgC;QAEhC,gBAAgB;QAChB,IAAI,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AE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,CAAA;QACrG,UAAU,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAA;QAEjD,IAAI,KAAc,CAAA;QAClB,IAAI,CAAC;YACD,MAAM,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QACxC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,KAAK,GAAG,CAAC,CAAA;QACb,CAAC;QAED,OAAO;YACH,GAAG;YACH,qBAAqB;YACrB,iBAAiB;YACjB,kBAAkB;YAClB,iBAAiB;YACjB,KAAK;SACR,CAAA;IACL,CAAC,CAAC,CAAA;AACN,CAAC;AAED,KAAK,UAAU,wBAAwB,CAAC,MAAmB,EAAE,OAAoB;IAC7E,IAAI,MAAM,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAA;QACvE,IAAI,UAAU;YAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IACnD,CAAC;AACL,CAAC","sourcesContent":["import { timeProfileAsync } from './timeProfier.js'\nimport { runTasks } from './runTasks.js'\nimport { addExports } from './addExports.js'\n\nimport type { FinalConfig, Describe, DescribeParcel, It, ParsedDescribe, TaskExports } from '../../types.js'\n\nexport function parseDescribe(\n config: FinalConfig,\n describe: Describe,\n itFilter?: string\n): Promise<ParsedDescribe> {\n return timeProfileAsync(`parse its from describe ${describe.thing}`, async () => {\n let itCounter = 1\n const its: It[] = []\n\n // create functions to pass back\n\n // afterDescribe\n let afterDescribeFunc: (() => void | Promise<void>) | undefined\n function afterDescribe(func: () => void | Promise<void>): void {\n if (typeof func !== 'function') {\n throw new Error('afterDescribe() error, argument passed to afterDescribe() must be a function,'\n + ` received ${typeof func}`)\n }\n afterDescribeFunc = func\n }\n\n // beforeEachTest\n let beforeEachTestFunc: (() => TaskExports | void | Promise<TaskExports | void>) | undefined\n function beforeEachTest(func: () => TaskExports | void | Promise<TaskExports | void>): void {\n if (typeof func !== 'function') {\n throw new Error('afterDescribe() error, argument passed to afterDescribe() must be a function,'\n + ` received ${typeof func}`)\n }\n beforeEachTestFunc = func\n }\n\n // afterEachTest\n let afterEachTestFunc: (() => void | Promise<void>) | undefined\n function afterEachTest(func: () => void | Promise<void>): void {\n if (typeof func !== 'function') {\n throw new Error('afterDescribe() error, argument passed to afterDescribe() must be a function,'\n + ` received ${typeof func}`)\n }\n afterEachTestFunc = func\n }\n\n // it\n function it(should: string, test: It['test']): void {\n const thisItCounter = itCounter++\n if (itFilter !== undefined && !should.toLowerCase().includes(itFilter.toLowerCase())) return\n its.push({\n counter: thisItCounter,\n should,\n test\n })\n }\n\n const beforeDescribeExports: TaskExports = {}\n await configBeforeEachDescribe(config, beforeDescribeExports)\n\n const describeParcel: DescribeParcel = { it, test: it, afterDescribe, beforeEachTest, afterEachTest }\n addExports(describeParcel, beforeDescribeExports)\n\n let error: unknown\n try {\n await describe.tests(describeParcel)\n } catch (e) {\n error = e\n }\n\n return {\n its,\n beforeDescribeExports,\n afterDescribeFunc,\n beforeEachTestFunc,\n afterEachTestFunc,\n error\n }\n })\n}\n\nasync function configBeforeEachDescribe(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.beforeEachDescribe !== undefined) {\n const theExports = await runTasks(config.beforeEachDescribe, undefined)\n if (theExports) addExports(exports, theExports)\n }\n}\n"]}
1
+ {"version":3,"file":"parseDescribe.js","sourceRoot":"","sources":["../../../src/cli/lib/parseDescribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI5C,MAAM,qBAAsB,SAAQ,KAAK;IACrC,IAAI,GAAG,uBAAuB,CAAA;CACjC;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R,CAAA;IACL,CAAC,CAAC,CAAA;AACN,CAAC;AAED,KAAK,UAAU,wBAAwB,CAAC,MAAmB,EAAE,OAAoB;IAC7E,IAAI,MAAM,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAA;QACvE,IAAI,UAAU;YAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IACnD,CAAC;AACL,CAAC","sourcesContent":["import { timeProfileAsync } from './timeProfier.js'\nimport { runTasks } from './runTasks.js'\nimport { addExports } from './addExports.js'\n\nimport type { FinalConfig, Describe, DescribeParcel, It, ParsedDescribe, TaskExports } from '../../types.js'\n\nclass SxytNotAFunctionError extends Error {\n name = 'SxytNotAFunctionError'\n}\nclass SxytAlreadyDefinedError extends Error {\n name = 'SxytAlreadyDefinedError'\n}\n\nfunction throwMustBeAFunctionError(fname: string, func: unknown): never {\n throw new SxytNotAFunctionError(`${fname}() error, argument passed to ${fname}() must be a function,`\n + ` received ${typeof func}`)\n}\n\nfunction throwAlreadyDefinedError(fname: string): never {\n throw new SxytAlreadyDefinedError(`${fname}() error, ${fname} function is already defined.`\n + ' Only one function is permitted')\n}\n\nexport function parseDescribe(\n config: FinalConfig,\n describe: Describe,\n itFilter?: string\n): Promise<ParsedDescribe> {\n return timeProfileAsync(`parse its from describe ${describe.thing}`, async () => {\n let itCounter = 1\n const its: It[] = []\n\n // create functions to pass back\n\n // afterDescribe\n let afterDescribeFunc: (() => void | Promise<void>) | undefined\n function afterDescribe(func: () => void | Promise<void>): void {\n if (typeof func !== 'function') {\n throwMustBeAFunctionError('afterDescribe', func)\n }\n if (afterDescribeFunc !== undefined) {\n throwAlreadyDefinedError('afterDescribe')\n }\n afterDescribeFunc = func\n }\n\n // beforeEachTest\n let beforeEachTestFunc: (() => TaskExports | void | Promise<TaskExports | void>) | undefined\n function beforeEachTest(func: () => TaskExports | void | Promise<TaskExports | void>): void {\n if (typeof func !== 'function') {\n throwMustBeAFunctionError('beforeEachTest', func)\n }\n if (beforeEachTestFunc !== undefined) {\n throwAlreadyDefinedError('beforeEachTest')\n }\n beforeEachTestFunc = func\n }\n\n // afterEachTest\n let afterEachTestFunc: (() => void | Promise<void>) | undefined\n function afterEachTest(func: () => void | Promise<void>): void {\n if (typeof func !== 'function') {\n throwMustBeAFunctionError('afterEachTest', func)\n }\n if (afterEachTestFunc !== undefined) {\n throwAlreadyDefinedError('afterEachTest')\n }\n afterEachTestFunc = func\n }\n\n // it\n function it(should: string, test: It['test']): void {\n const thisItCounter = itCounter++\n if (itFilter !== undefined && !should.toLowerCase().includes(itFilter.toLowerCase())) return\n its.push({\n counter: thisItCounter,\n should,\n test\n })\n }\n\n const beforeDescribeExports: TaskExports = {}\n await configBeforeEachDescribe(config, beforeDescribeExports)\n\n const describeParcel: DescribeParcel = { it, test: it, afterDescribe, beforeEachTest, afterEachTest }\n addExports(describeParcel, beforeDescribeExports)\n\n let error: unknown\n try {\n await describe.tests(describeParcel)\n } catch (e) {\n error = e\n }\n\n return {\n its,\n beforeDescribeExports,\n afterDescribeFunc,\n beforeEachTestFunc,\n afterEachTestFunc,\n error\n }\n })\n}\n\nasync function configBeforeEachDescribe(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.beforeEachDescribe !== undefined) {\n const theExports = await runTasks(config.beforeEachDescribe, undefined)\n if (theExports) addExports(exports, theExports)\n }\n}\n"]}
@@ -8,7 +8,7 @@ type RunReqest = {
8
8
  };
9
9
  export type ReRunManager = {
10
10
  state: ReRunManageState;
11
- requestRun: (type: RunType, callback: () => RunTestsPromise) => void;
11
+ requestRun: (type: RunType, callback: () => RunTestsPromise) => Promise<void>;
12
12
  __test: {
13
13
  waiting: boolean;
14
14
  queue: RunReqest[];
@@ -4,6 +4,7 @@ import { agentSetRunReason } from './agentReport.js';
4
4
  import chalk from '../../packages/chalk.js';
5
5
  export function makeReRunManager(currentRun, state,
6
6
  //callback: () => RunTestsPromise
7
+ //concurrency: Concurrency,
7
8
  customOut) {
8
9
  // agent mode passes a sink - runTests reports the run instead
9
10
  const out = customOut ?? mainOut;
@@ -1 +1 @@
1
- {"version":3,"file":"reRunManager.js","sourceRoot":"","sources":["../../../src/cli/lib/reRunManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAI5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAsB3C,MAAM,UAAU,gBAAgB,CAC5B,UAAkC,EAClC,KAAuB;AACvB,iCAAiC;AACjC,SAAiB;IAEjB,8DAA8D;IAC9D,MAAM,GAAG,GAAG,SAAS,IAAI,OAAO,CAAA;IAChC,IAAI,KAAK,GAAgB,EAAE,CAAA;IAC3B,IAAI,OAAO,GAAG,KAAK,CAAA;IAEnB,MAAM,MAAM,GAAG;QACX,OAAO;QACP,KAAK;KACR,CAAA;IAED,KAAK,UAAU,YAAY;QAEvB,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAEzB,IAAI,OAAO;YAAE,OAAM,CAAC,wDAAwD;QAC5E,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,IAAI,CAAA,CAAC,2BAA2B;QAC3D,MAAM,UAAU,CAAA,CAAC,uBAAuB;QACxC,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,KAAK,CAAA;QAEhC,KAAK,CAAC,eAAe,CAAC,CAAA;QAEtB,oCAAoC;QACpC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;QAClC,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;QAC/B,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;QAC7B,IAAI,SAAS,K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tD,YAAY;YAEZ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBAClB,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA;gBAC3D,KAAK,CAAC,IAAI,CAAC;oBACP,IAAI;oBACJ,QAAQ;oBACR,QAAQ;iBACX,CAAC,CAAA;YACN,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA;gBAC3D,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC;wBACpB,IAAI;wBACJ,QAAQ;wBACR,QAAQ;qBACX,CAAC,CAAA;YACN,CAAC;YACD,KAAK,CAAC,gBAAgB,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;YACvC,uBAAuB;YACvB,OAAO,YAAY,EAAE,CAAA,CAAC,2DAA2D;QACrF,CAAC;QACD,MAAM;KACT,CAAA;AACL,CAAC","sourcesContent":["import { inspect } from 'util'\nimport { debug, log, out as mainOut } from '../../output.js'\nimport { ReRunManageState } from './makeWatchRunState.js'\nimport type { RunTestsPromise } from './runTests.js'\nimport type { OutFn } from '../../types.js'\nimport { agentSetRunReason } from './agentReport.js'\nimport chalk from '../../packages/chalk.js'\n\nexport type RunType = 'auto' | 'all' | 'last' | 'failed'\n\ntype RunReqest = {\n type: RunType\n //tests: string[] | Set<string>\n callback: () => RunTestsPromise\n}\n\n//export type ReRunManager = ReturnType<typeof makeReRunManager>\n\nexport type ReRunManager = {\n state: ReRunManageState\n requestRun: (type: RunType, callback: () => RunTestsPromise) => void\n __test: {\n waiting: boolean\n queue: RunReqest[]\n }\n}\n\n\nexport function makeReRunManager(\n currentRun: RunTestsPromise | null,\n state: ReRunManageState,\n //callback: () => RunTestsPromise\n customOut?: OutFn\n): ReRunManager {\n // agent mode passes a sink - runTests reports the run instead\n const out = customOut ?? mainOut\n let queue: RunReqest[] = []\n let waiting = false\n\n const __test = {\n waiting,\n queue\n }\n\n async function processQueue() {\n \n debug('processing queue')\n\n if (waiting) return // do nothing if another processQueue is already waiting\n __test.waiting = waiting = true // mark that we are waiting\n await currentRun // wait for current run\n __test.waiting = waiting = false\n\n debug('done waitinng')\n\n // see if there is a request waiting\n debug('the queue', inspect(queue))\n const runReqest = queue.shift()\n debug('runReqest', runReqest)\n if (runReqest === undefined) return\n\n // tells the run about to start why it is running, for the agent `why=` field\n agentSetRunReason(runReqest.type)\n\n switch (runReqest.type) {\n case 'all': {\n out(chalk.brightblue`re-running all tests...`)\n break\n }\n case 'last': {\n out(chalk.brightblue`re-running last tests...`)\n break\n }\n case 'failed': {\n out(chalk.brightblue`re-running failed tests...`)\n break\n }\n case 'auto': {\n out(chalk.brightblue`running tests due to file changes`)\n break\n }\n default: throw new Error('Unrecognised run type')\n }\n\n // run it and save it\n debug('calling', runReqest.callback.toString())\n currentRun = runReqest.callback()\n state.currentRun = currentRun\n // wait for the run then trigger another processQueue\n await currentRun\n // if one has already been started by a run request\n // then this won't start a new one. This is used to\n // clear a queue if it has built it\n processQueue().catch(err => log(`processQueue threw an error: ${err}`))\n }\n\n return {\n state,\n requestRun(type: RunType, callback: () => RunTestsPromise) {\n\n // if it's type auto, we only want to keep one, but\n // we want it to include all relevant tests when it runs\n\n // if it's a human triggered type, we'll replace other\n // human requests, but leave the auto, so the user\n // can see update to changed code that would be hidden\n // otherwise\n \n if (type === 'auto') {\n __test.queue = queue = queue.filter(x => x.type !== 'auto')\n queue.push({\n type,\n //tests,\n callback\n })\n } else {\n __test.queue = queue = queue.filter(x => x.type === 'auto')\n __test.queue = queue = [{\n type,\n //tests,\n callback\n }]\n }\n debug('added to queue', inspect(queue))\n // see if we can run it\n return processQueue() //.catch(err => log(`processQueue threw an error: ${err}`))\n },\n __test\n }\n}\n\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CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA;gBAC3D,KAAK,CAAC,IAAI,CAAC;oBACP,IAAI;oBACJ,QAAQ;oBACR,QAAQ;iBACX,CAAC,CAAA;YACN,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA;gBAC3D,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC;wBACpB,IAAI;wBACJ,QAAQ;wBACR,QAAQ;qBACX,CAAC,CAAA;YACN,CAAC;YACD,KAAK,CAAC,gBAAgB,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;YACvC,uBAAuB;YACvB,OAAO,YAAY,EAAE,CAAA,CAAC,2DAA2D;QACrF,CAAC;QACD,MAAM;KACT,CAAA;AACL,CAAC","sourcesContent":["import { inspect } from 'util'\nimport { debug, log, out as mainOut } from '../../output.js'\nimport { ReRunManageState } from './makeWatchRunState.js'\nimport type { Concurrency, RunTestsPromise } from './runTests.js'\nimport type { OutFn } from '../../types.js'\nimport { agentSetRunReason } from './agentReport.js'\nimport chalk from '../../packages/chalk.js'\n\nexport type RunType = 'auto' | 'all' | 'last' | 'failed'\n\ntype RunReqest = {\n type: RunType\n //tests: string[] | Set<string>\n callback: () => RunTestsPromise\n}\n\n//export type ReRunManager = ReturnType<typeof makeReRunManager>\n\nexport type ReRunManager = {\n state: ReRunManageState\n requestRun: (type: RunType, callback: () => RunTestsPromise) => Promise<void>\n __test: {\n waiting: boolean\n queue: RunReqest[]\n }\n}\n\n\nexport function makeReRunManager(\n currentRun: RunTestsPromise | null,\n state: ReRunManageState,\n //callback: () => RunTestsPromise\n //concurrency: Concurrency,\n customOut?: OutFn\n): ReRunManager {\n // agent mode passes a sink - runTests reports the run instead\n const out = customOut ?? mainOut\n let queue: RunReqest[] = []\n let waiting = false\n\n const __test = {\n waiting,\n queue\n }\n\n async function processQueue() {\n \n debug('processing queue')\n\n if (waiting) return // do nothing if another processQueue is already waiting\n __test.waiting = waiting = true // mark that we are waiting\n await currentRun // wait for current run\n __test.waiting = waiting = false\n\n debug('done waitinng')\n\n // see if there is a request waiting\n debug('the queue', inspect(queue))\n const runReqest = queue.shift()\n debug('runReqest', runReqest)\n if (runReqest === undefined) return\n\n // tells the run about to start why it is running, for the agent `why=` field\n agentSetRunReason(runReqest.type)\n\n switch (runReqest.type) {\n case 'all': {\n out(chalk.brightblue`re-running all tests...`)\n break\n }\n case 'last': {\n out(chalk.brightblue`re-running last tests...`)\n break\n }\n case 'failed': {\n out(chalk.brightblue`re-running failed tests...`)\n break\n }\n case 'auto': {\n out(chalk.brightblue`running tests due to file changes`)\n break\n }\n default: throw new Error('Unrecognised run type')\n }\n\n // run it and save it\n debug('calling', runReqest.callback.toString())\n currentRun = runReqest.callback()\n state.currentRun = currentRun\n // wait for the run then trigger another processQueue\n await currentRun\n // if one has already been started by a run request\n // then this won't start a new one. This is used to\n // clear a queue if it has built it\n processQueue().catch(err => log(`processQueue threw an error: ${err}`))\n }\n\n return {\n state,\n requestRun(type: RunType, callback: () => RunTestsPromise) {\n\n // if it's type auto, we only want to keep one, but\n // we want it to include all relevant tests when it runs\n\n // if it's a human triggered type, we'll replace other\n // human requests, but leave the auto, so the user\n // can see update to changed code that would be hidden\n // otherwise\n \n if (type === 'auto') {\n __test.queue = queue = queue.filter(x => x.type !== 'auto')\n queue.push({\n type,\n //tests,\n callback\n })\n } else {\n __test.queue = queue = queue.filter(x => x.type === 'auto')\n __test.queue = queue = [{\n type,\n //tests,\n callback\n }]\n }\n debug('added to queue', inspect(queue))\n // see if we can run it\n return processQueue() //.catch(err => log(`processQueue threw an error: ${err}`))\n },\n __test\n }\n}\n\n\n"]}
@@ -6,6 +6,8 @@ import { makeStopSignal, stopIfFailFast } from './stopSignal.js';
6
6
  export function runDescribeRun(config, describe, parsedIts, stop = makeStopSignal()) {
7
7
  return timeProfileAsync(`run describe, run its ${describe.thing}`, async () => {
8
8
  const { its, beforeDescribeExports, afterDescribeFunc, beforeEachTestFunc, afterEachTestFunc } = parsedIts;
9
+ // describe() rejects a meta naming neither key, so the else branch can only be a
10
+ // sequentialTests one
9
11
  const parallelOverride = describe.meta === undefined
10
12
  ? undefined
11
13
  : 'parallelTests' in describe.meta ? describe.meta.parallelTests : !describe.meta.sequentialTests;
@@ -1 +1 @@
1
- {"version":3,"file":"runDescribeRun.js","sourceRoot":"","sources":["../../../src/cli/lib/runDescribeRun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAA;AAMjF,MAAM,UAAU,cAAc,CAC1B,MAAmB,EACnB,QAAkB,EAClB,SAAyB,EACzB,OAAmB,cAAc,EAAE;IAEnC,OAAO,gBAAgB,CAAC,yBAAyB,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,IAAI,EAAE;QAC1E,MAAM,EAAE,GAAG,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,SAAS,CAAA;QAE1G,MAAM,gBAAgB,GAAG,QAAQ,CAAC,IAAI,KAAK,SAAS;YAChD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,eAAe,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAA;QAErG,MAAM,UAAU,GAAG,gBAAgB,IAAI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AAG,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,KAAK,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YACjG,IAAI,EAAE,CAAC,EAAE,6BAA6B;YACtC,SAAS;YACT,gBAAgB;SACnB,CAAA;QAED,YAAY;QACZ,IAAI,OAAO,iBAAiB,KAAK,UAAU;YAAE,MAAM,iBAAiB,EAAE,CAAA;QACtE,MAAM,uBAAuB,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;QAE5D,OAAO,cAAc,CAAA;IACzB,CAAC,CAAC,CAAA;AACN,CAAC;AAED,KAAK,UAAU,uBAAuB,CAAC,MAAmB,EAAE,OAAoB;IAC5E,IAAI,MAAM,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;AACL,CAAC","sourcesContent":["import { timeProfileAsync } from './timeProfier.js'\nimport { runTasks } from './runTasks.js'\nimport { debug } from '../../output.js'\nimport { runIt } from './runIt.js'\n\nimport { makeStopSignal, stopIfFailFast, type StopSignal } from './stopSignal.js'\n\nimport type {\n FinalConfig, Describe, DescribeResult, ItResult, ItResultsSummary, ParsedDescribe, TaskExports\n} from '../../types.js'\n\nexport function runDescribeRun(\n config: FinalConfig,\n describe: Describe,\n parsedIts: ParsedDescribe,\n stop: StopSignal = makeStopSignal()\n): Promise<DescribeResult> {\n return timeProfileAsync(`run describe, run its ${describe.thing}`, async () => {\n const { its, beforeDescribeExports, afterDescribeFunc, beforeEachTestFunc, afterEachTestFunc } = parsedIts\n\n const parallelOverride = describe.meta === undefined\n ? undefined\n : 'parallelTests' in describe.meta ? describe.meta.parallelTests : !describe.meta.sequentialTests\n\n const isParallel = parallelOverride ?? config.execution.tests === 'parallel'\n\n const itPromises: Array<Promise<ItResult>> = []\n for (const it of its) {\n // checked before starting, so the failing test is the last one that runs\n if (stop.stopped) break\n const itPromise = runIt(config, it, beforeEachTestFunc, afterEachTestFunc)\n itPromises.push(itPromise)\n if (!isParallel) stopIfFailFast(config, stop, (await itPromise).success === false)\n }\n const itResults = await Promise.all(itPromises)\n\n // in parallel mode the tests are already in flight, so this only stops later work\n stopIfFailFast(config, stop, itResults.some(itResult => itResult.success === false))\n\n const itResultsSummary: ItResultsSummary = {\n total: 0,\n passes: 0\n }\n\n for (const itResult of itResults) {\n itResultsSummary.total += +(itResult.success !== null)\n itResultsSummary.passes += +(itResult.success ?? false)\n }\n\n debug('itResultsSummary', itResultsSummary)\n\n const describeResult: DescribeResult = {\n counter: describe.counter,\n thing: describe.thing,\n success: (itResultsSummary.total > 0) ? itResultsSummary.passes === itResultsSummary.total : null,\n time: 0, // overwritten by runDescribe\n itResults,\n itResultsSummary\n }\n\n // run after\n if (typeof afterDescribeFunc === 'function') await afterDescribeFunc()\n await configAfterEachDescribe(config, beforeDescribeExports)\n\n return describeResult\n })\n}\n\nasync function configAfterEachDescribe(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.afterEachDescribe !== undefined) {\n await runTasks(config.afterEachDescribe, exports)\n }\n}\n"]}
1
+ {"version":3,"file":"runDescribeRun.js","sourceRoot":"","sources":["../../../src/cli/lib/runDescribeRun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAA;AAMjF,MAAM,UAAU,cAAc,CAC1B,MAAmB,EACnB,QAAkB,EAClB,SAAyB,EACzB,OAAmB,cAAc,EAAE;IAEnC,OAAO,gBAAgB,CAAC,yBAAyB,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,IAAI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M,QAAQ,IAAI,SAAS,EAAE,CAAC;YAC/B,gBAAgB,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,IAAI,CAAC,CAAA;YACtD,gBAAgB,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,IAAI,KAAK,CAAC,CAAA;QAC3D,CAAC;QAED,KAAK,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;QAE3C,MAAM,cAAc,GAAmB;YACnC,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,OAAO,EAAE,CAAC,gBAAgB,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,KAAK,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YACjG,IAAI,EAAE,CAAC,EAAE,6BAA6B;YACtC,SAAS;YACT,gBAAgB;SACnB,CAAA;QAED,YAAY;QACZ,IAAI,OAAO,iBAAiB,KAAK,UAAU;YAAE,MAAM,iBAAiB,EAAE,CAAA;QACtE,MAAM,uBAAuB,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;QAE5D,OAAO,cAAc,CAAA;IACzB,CAAC,CAAC,CAAA;AACN,CAAC;AAED,KAAK,UAAU,uBAAuB,CAAC,MAAmB,EAAE,OAAoB;IAC5E,IAAI,MAAM,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;AACL,CAAC","sourcesContent":["import { timeProfileAsync } from './timeProfier.js'\nimport { runTasks } from './runTasks.js'\nimport { debug } from '../../output.js'\nimport { runIt } from './runIt.js'\n\nimport { makeStopSignal, stopIfFailFast, type StopSignal } from './stopSignal.js'\n\nimport type {\n FinalConfig, Describe, DescribeResult, ItResult, ItResultsSummary, ParsedDescribe, TaskExports\n} from '../../types.js'\n\nexport function runDescribeRun(\n config: FinalConfig,\n describe: Describe,\n parsedIts: ParsedDescribe,\n stop: StopSignal = makeStopSignal()\n): Promise<DescribeResult> {\n return timeProfileAsync(`run describe, run its ${describe.thing}`, async () => {\n const { its, beforeDescribeExports, afterDescribeFunc, beforeEachTestFunc, afterEachTestFunc } = parsedIts\n\n // describe() rejects a meta naming neither key, so the else branch can only be a\n // sequentialTests one\n const parallelOverride = describe.meta === undefined\n ? undefined\n : 'parallelTests' in describe.meta ? describe.meta.parallelTests : !describe.meta.sequentialTests\n\n const isParallel = parallelOverride ?? config.execution.tests === 'parallel'\n\n const itPromises: Array<Promise<ItResult>> = []\n for (const it of its) {\n // checked before starting, so the failing test is the last one that runs\n if (stop.stopped) break\n const itPromise = runIt(config, it, beforeEachTestFunc, afterEachTestFunc)\n itPromises.push(itPromise)\n if (!isParallel) stopIfFailFast(config, stop, (await itPromise).success === false)\n }\n const itResults = await Promise.all(itPromises)\n\n // in parallel mode the tests are already in flight, so this only stops later work\n stopIfFailFast(config, stop, itResults.some(itResult => itResult.success === false))\n\n const itResultsSummary: ItResultsSummary = {\n total: 0,\n passes: 0\n }\n\n for (const itResult of itResults) {\n itResultsSummary.total += +(itResult.success !== null)\n itResultsSummary.passes += +(itResult.success ?? false)\n }\n\n debug('itResultsSummary', itResultsSummary)\n\n const describeResult: DescribeResult = {\n counter: describe.counter,\n thing: describe.thing,\n success: (itResultsSummary.total > 0) ? itResultsSummary.passes === itResultsSummary.total : null,\n time: 0, // overwritten by runDescribe\n itResults,\n itResultsSummary\n }\n\n // run after\n if (typeof afterDescribeFunc === 'function') await afterDescribeFunc()\n await configAfterEachDescribe(config, beforeDescribeExports)\n\n return describeResult\n })\n}\n\nasync function configAfterEachDescribe(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.afterEachDescribe !== undefined) {\n await runTasks(config.afterEachDescribe, exports)\n }\n}\n"]}
@@ -12,6 +12,8 @@ export function runTest(config, test, filters = {}, stop = makeStopSignal()) {
12
12
  // run before test file
13
13
  const fileExports = {};
14
14
  await configBeforeEachFile(config, fileExports);
15
+ // meta() rejects a meta naming neither key, so the else branch can only be a
16
+ // sequentialDescribes one
15
17
  const parallelOverride = test.meta === undefined
16
18
  ? undefined
17
19
  : 'parallelDescribes' in test.meta ? test.meta.parallelDescribes : !test.meta.sequentialDescribes;
@@ -1 +1 @@
1
- {"version":3,"file":"runTest.js","sourceRoot":"","sources":["../../../src/cli/lib/runTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAmC,MAAM,iBAAiB,CAAA;AAMjF,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAElE,MAAM,UAAU,OAAO,CACnB,MAAmB,EACnB,IAAc,EACd,UAAgC,EAAE,EAClC,OAAmB,cAAc,EAAE;IAEnC,OAAO,gBAAgB,CAAC,YAAY,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,IAAI,EAAE;QACxD,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAEnB,uBAAuB;QACvB,MAAM,WAAW,GAAgB,EAAE,CAAA;QACnC,MAAM,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAE/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS;YAC5C,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,mBAAmB,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,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,SAAS,EAAE,CAAC;QACrC,MAAM,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;AACL,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { debug } from '../../output.js'\nimport { showTimeProfiling } from '../../config.js'\n\nimport { runTasks } from './runTasks.js'\nimport { addExports } from './addExports.js'\nimport { runDescribe } from './runDescribe.js'\n\nimport { makeStopSignal, stopIfFailFast, type StopSignal } from './stopSignal.js'\n\nimport type {\n FinalConfig, DescribeResult, DescribeResultsSummary, TaskExports, TestExecutionFilters, TestFile, TestResult\n} from '../../types.js'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport function runTest(\n config: FinalConfig,\n test: TestFile,\n filters: TestExecutionFilters = {},\n stop: StopSignal = makeStopSignal()\n): Promise<TestResult> {\n return timeProfileAsync(`run test ${test.file}`, async () => {\n debug('test', test)\n\n // run before test file\n const fileExports: TaskExports = {}\n await configBeforeEachFile(config, fileExports)\n\n const parallelOverride = test.meta === undefined\n ? undefined\n : 'parallelDescribes' in test.meta ? test.meta.parallelDescribes : !test.meta.sequentialDescribes\n\n const isParallel = parallelOverride ?? config.execution.describes === 'parallel'\n\n const runDescribePromises: Array<Promise<DescribeResult>> = []\n\n for (const describe of test.describes ?? []) {\n // a failure in an earlier describe leaves the rest of the file unrun\n if (stop.stopped) break\n\n if (\n filters.describe !== undefined\n && !describe.thing.toLowerCase().includes(filters.describe.toLowerCase())\n ) continue\n\n const describePromise = runDescribe(config, describe, filters.it, stop)\n runDescribePromises.push(describePromise)\n if (!isParallel) await describePromise\n }\n\n let describeResults = await Promise.all(runDescribePromises)\n if (filters.it !== undefined) {\n describeResults = describeResults.filter(result => (\n result.itResults.length > 0 || result.error !== undefined\n ))\n }\n\n const describeResultsSummary: DescribeResultsSummary = {\n total: 0,\n passes: 0,\n invalid: 0,\n itsTotal: 0,\n itsPasses: 0\n }\n\n for (const describeResult of describeResults) {\n describeResultsSummary.total += +(describeResult.success !== null)\n describeResultsSummary.passes += +(describeResult.success ?? false)\n describeResultsSummary.invalid += +(describeResult.success === null)\n describeResultsSummary.itsTotal += describeResult.itResultsSummary.total\n describeResultsSummary.itsPasses += describeResult.itResultsSummary.passes\n }\n\n const testResults: TestResult = {\n file: test.file,\n success: (describeResultsSummary.total > 0)\n ? describeResultsSummary.total === describeResultsSummary.passes\n : null,\n describeResults,\n describeResultsSummary,\n logs: test.logs ?? []\n }\n\n // run after test\n await configAfterEachFile(config, fileExports)\n\n return testResults\n })\n}\n\nasync function configBeforeEachFile(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.beforeEachFile !== undefined) {\n const theExports = await runTasks(config.beforeEachFile, undefined)\n if (theExports) addExports(exports, theExports)\n }\n}\n\nasync function configAfterEachFile(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.afterEachFile !== undefined) {\n await runTasks(config.afterEachFile, exports)\n }\n}\n"]}
1
+ {"version":3,"file":"runTest.js","sourceRoot":"","sources":["../../../src/cli/lib/runTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAmC,MAAM,iBAAiB,CAAA;AAMjF,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAElE,MAAM,UAAU,OAAO,CACnB,MAAmB,EACnB,IAAc,EACd,UAAgC,EAAE,EAClC,OAAmB,cAAc,EAAE;IAEnC,OAAO,gBAAgB,CAAC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ACtB,CAAC,CAAC,CAAA;AACN,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,MAAmB,EAAE,OAAoB;IACzE,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,CAAA;QACnE,IAAI,UAAU;YAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IACnD,CAAC;AACL,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,MAAmB,EAAE,OAAoB;IACxE,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;AACL,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { debug } from '../../output.js'\nimport { showTimeProfiling } from '../../config.js'\n\nimport { runTasks } from './runTasks.js'\nimport { addExports } from './addExports.js'\nimport { runDescribe } from './runDescribe.js'\n\nimport { makeStopSignal, stopIfFailFast, type StopSignal } from './stopSignal.js'\n\nimport type {\n FinalConfig, DescribeResult, DescribeResultsSummary, TaskExports, TestExecutionFilters, TestFile, TestResult\n} from '../../types.js'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport function runTest(\n config: FinalConfig,\n test: TestFile,\n filters: TestExecutionFilters = {},\n stop: StopSignal = makeStopSignal()\n): Promise<TestResult> {\n return timeProfileAsync(`run test ${test.file}`, async () => {\n debug('test', test)\n\n // run before test file\n const fileExports: TaskExports = {}\n await configBeforeEachFile(config, fileExports)\n\n // meta() rejects a meta naming neither key, so the else branch can only be a\n // sequentialDescribes one\n const parallelOverride = test.meta === undefined\n ? undefined\n : 'parallelDescribes' in test.meta ? test.meta.parallelDescribes : !test.meta.sequentialDescribes\n\n const isParallel = parallelOverride ?? config.execution.describes === 'parallel'\n\n const runDescribePromises: Array<Promise<DescribeResult>> = []\n\n for (const describe of test.describes ?? []) {\n // a failure in an earlier describe leaves the rest of the file unrun\n if (stop.stopped) break\n\n if (\n filters.describe !== undefined\n && !describe.thing.toLowerCase().includes(filters.describe.toLowerCase())\n ) continue\n\n const describePromise = runDescribe(config, describe, filters.it, stop)\n runDescribePromises.push(describePromise)\n if (!isParallel) await describePromise\n }\n\n let describeResults = await Promise.all(runDescribePromises)\n if (filters.it !== undefined) {\n describeResults = describeResults.filter(result => (\n result.itResults.length > 0 || result.error !== undefined\n ))\n }\n\n const describeResultsSummary: DescribeResultsSummary = {\n total: 0,\n passes: 0,\n invalid: 0,\n itsTotal: 0,\n itsPasses: 0\n }\n\n for (const describeResult of describeResults) {\n describeResultsSummary.total += +(describeResult.success !== null)\n describeResultsSummary.passes += +(describeResult.success ?? false)\n describeResultsSummary.invalid += +(describeResult.success === null)\n describeResultsSummary.itsTotal += describeResult.itResultsSummary.total\n describeResultsSummary.itsPasses += describeResult.itResultsSummary.passes\n }\n\n const testResults: TestResult = {\n file: test.file,\n success: (describeResultsSummary.total > 0)\n ? describeResultsSummary.total === describeResultsSummary.passes\n : null,\n describeResults,\n describeResultsSummary,\n logs: test.logs ?? []\n }\n\n // run after test\n await configAfterEachFile(config, fileExports)\n\n return testResults\n })\n}\n\nasync function configBeforeEachFile(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.beforeEachFile !== undefined) {\n const theExports = await runTasks(config.beforeEachFile, undefined)\n if (theExports) addExports(exports, theExports)\n }\n}\n\nasync function configAfterEachFile(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.afterEachFile !== undefined) {\n await runTasks(config.afterEachFile, exports)\n }\n}\n"]}
@@ -1,5 +1,8 @@
1
1
  import type { FinalConfig, OutFn, TestExecutionFilters } from '../../types.js';
2
2
  import { ReRunManager } from './reRunManager.js';
3
3
  export type RunTestsPromise = Promise<boolean | null>;
4
- export declare function runTests(config: FinalConfig, testFiles: Set<string>, reRunManager: ReRunManager | undefined, refresh?: 'refresh' | 'cached', customOut?: OutFn, filters?: TestExecutionFilters): RunTestsPromise;
4
+ export type Concurrency = {
5
+ limit: number;
6
+ };
7
+ export declare function runTests(config: FinalConfig, testFiles: Set<string>, reRunManager: ReRunManager | undefined, concurrency?: Concurrency, refresh?: 'refresh' | 'cached', customOut?: OutFn, filters?: TestExecutionFilters): RunTestsPromise;
5
8
  //# sourceMappingURL=runTests.d.ts.map
@@ -25,7 +25,7 @@ function plural(count, noun, verb) {
25
25
  return '';
26
26
  return `${count} ${noun}${count === 1 ? '' : 's'} ${verb}`;
27
27
  }
28
- export async function runTests(config, testFiles, reRunManager, refresh = 'refresh', customOut, filters = {}) {
28
+ export async function runTests(config, testFiles, reRunManager, concurrency = { limit: -1 }, refresh = 'refresh', customOut, filters = {}) {
29
29
  if (reRunManager !== undefined) {
30
30
  reRunManager.state.lastTestFiles = new Set(testFiles);
31
31
  reRunManager.state.activeRuns++; // whatever, obsolete. Can use it to check on things
@@ -1 +1 @@
1
- {"version":3,"file":"runTests.js","sourceRoot":"","sources":["../../../src/cli/lib/runTests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,cAAc,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QAAQ;oBAAE,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;gBACvE,SAAS,CACL,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mBAAmB,EAAE,UAAU,EACpE,KAAK,CAAC,eAAe,CAAC,IAAI,CAC7B,CAAA;YACL,CAAC;YAED,gBAAgB;YAChB,uDAAuD;YACvD,OAAO,SAAS,CAAA;QACpB,CAAC,CAAC,CAAA;IACN,CAAC;YAAS,CAAC;QACP,IAAI,YAAY,KAAK,SAAS;YAAE,YAAY,CAAC,KAAK,CAAC,UAAU,EAAE,CAAA;IACnE,CAAC;AACL,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport chalk from '../../packages/chalk.js'\nimport { out as mainOut } from '../../output.js'\nimport figures from '../../packages/figures.js'\nimport { count } from 'sxy-lib/objects.js'\nimport { remove as arrayRemove } from 'sxy-lib/arrays.js'\nimport { allObj as promiseAllObj } from 'sxy-lib/promises.js'\n\nimport { loadTestFile } from './loadTestFile.js'\nimport { runTest } from './runTest.js'\nimport { showTestLoadingError } from './showTestLoadingError.js'\nimport { showTestResult } from './showTestResult.js'\nimport { failureLines } from './failureLines.js'\nimport { failureEntries } from './failureEntries.js'\nimport { agentDone, agentFailure, agentRunStart } from './agentReport.js'\nimport { makeStopSignal, stopIfFailFast } from './stopSignal.js'\nimport { statusCodes, writeStatusFile } from './statusFile.js'\n\nimport type {\n FinalConfig, OutFn, TestExecutionFilters, TestFile, TestResult, TestsResultsSummary\n} from '../../types.js'\nimport { makeRunManagerState, ReRunManageState } from './makeWatchRunState.js'\nimport { ReRunManager } from './reRunManager.js'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport type RunTestsPromise = Promise<boolean | null>\n\n// the summary lines, minus the colouring, for the status file\nfunction joinPlain(...parts: string[]): string {\n return parts.filter(part => part !== '').join(' ')\n}\n\nfunction plural(count: number, noun: string, verb: string): string {\n if (count < 1) return ''\n return `${count} ${noun}${count === 1 ? '' : 's'} ${verb}`\n}\n\n\nexport async function runTests(\n config: FinalConfig,\n testFiles: Set<string>,\n reRunManager: ReRunManager | undefined,\n refresh: 'refresh' | 'cached' = 'refresh',\n customOut?: OutFn,\n filters: TestExecutionFilters = {}\n): RunTestsPromise {\n if (reRunManager !== undefined) {\n reRunManager.state.lastTestFiles = new Set(testFiles)\n reRunManager.state.activeRuns++ // whatever, obsolete. Can use it to check on things\n }\n\n const state = reRunManager?.state || makeRunManagerState()\n const runStartTime = new Date().getTime()\n const agentRun = agentRunStart(config, testFiles.size)\n const stop = makeStopSignal()\n //console.log('new runTests:', watchRunState?.activeRuns)\n //console.log(inspect(testFiles))\n\n try {\n const testRunPromises: Record<string, Promise<TestResult>> = {}\n const erroringTests: Record<string, TestFile> = {}\n const testRunOutPromises: Record<string, Promise<void>> = {}\n\n await timeProfileAsync('run tests', async () => {\n if (Array.isArray(testFiles) ? testFiles.length > 0 : testFiles.size > 0) {\n for (const testFile of testFiles) {\n //console.log('testFiles', testFiles)\n //console.log('testFile', testFile)\n\n // an earlier file failed under failFast - leave the rest unloaded\n if (stop.stopped) break\n\n const test = await loadTestFile(config, testFile, refresh)\n\n if (test.error !== undefined && test.error !== false) {\n erroringTests[testFile] = test\n state.failedTestFiles.add(testFile)\n showTestLoadingError(config, test, customOut)\n stopIfFailFast(config, stop, true)\n } else {\n const testRunPromise = runTest(config, test, filters, stop)\n testRunPromises[testFile] = testRunPromise\n\n testRunOutPromises[testFile] = testRunPromise.then(async testResult => {\n if (testResult.success === true || testResult.success === null) {\n state.failedTestFiles.delete(testResult.file)\n } else {\n state.failedTestFiles.add(testFile)\n }\n const executionFilterActive = filters.describe !== undefined || filters.it !== undefined\n if (!executionFilterActive || testResult.describeResultsSummary.itsTotal > 0) {\n await showTestResult(config, testResult, customOut)\n }\n })\n\n // wait for the test to complete before proceeding if we are in 'sequential' mode\n if (config.execution.files === 'sequential') await testRunOutPromises[testFile]\n }\n }\n }\n })\n\n let runTestResults: Record<string, TestResult> = {}\n\n await timeProfileAsync('wait for tests to finish', async () => {\n runTestResults = await promiseAllObj(testRunPromises)\n\n // wait for the output to complete\n await promiseAllObj(testRunOutPromises)\n })\n\n return await timeProfileAsync('show initial test run results', () => {\n \n const out = customOut ?? mainOut\n\n const testsResultsSummary: TestsResultsSummary = {\n total: 0,\n passes: 0,\n invalid: 0,\n describesTotal: 0,\n describesPasses: 0,\n describesInvalid: 0,\n itsTotal: 0,\n itsPasses: 0\n // itsInvalid: 0 // we don't check whether tests run any asserts (we don't control the assertion lib)\n }\n let describesThrownCount = 0\n\n for (const testFile in runTestResults) {\n const runTestResult = runTestResults[testFile]\n if (!runTestResult) continue\n\n testsResultsSummary.total += +(runTestResult.success !== null)\n testsResultsSummary.passes += +(runTestResult.success ?? false)\n testsResultsSummary.invalid += +(runTestResult.success === null)\n testsResultsSummary.describesTotal += runTestResult.describeResultsSummary.total\n testsResultsSummary.describesPasses += runTestResult.describeResultsSummary.passes\n testsResultsSummary.describesInvalid += runTestResult.describeResultsSummary.invalid\n testsResultsSummary.itsTotal += runTestResult.describeResultsSummary.itsTotal\n testsResultsSummary.itsPasses += runTestResult.describeResultsSummary.itsPasses\n describesThrownCount += runTestResult.describeResults\n .filter(describeResult => describeResult.error !== undefined)\n .length\n }\n\n const failedToLoadCount = count(erroringTests)\n testsResultsSummary.total += failedToLoadCount\n\n if (\n (filters.describe !== undefined || filters.it !== undefined)\n && testsResultsSummary.itsTotal === 0\n && failedToLoadCount === 0\n && describesThrownCount === 0\n ) {\n out(chalk.orange('No tests matched the describe/test filters.'))\n const durationMs = new Date().getTime() - runStartTime\n writeStatusFile(\n config,\n statusCodes.couldNotRun,\n 'no tests matched the describe/test filters',\n [],\n durationMs\n )\n agentDone(\n config, agentRun, statusCodes.couldNotRun,\n 'no tests matched the describe/test filters', testsResultsSummary, durationMs,\n state.failedTestFiles.size\n )\n return null\n }\n\n out('\\n')\n\n const allPassed = (\n testsResultsSummary.passes === testsResultsSummary.total\n && testsResultsSummary.describesPasses === testsResultsSummary.describesTotal\n && testsResultsSummary.itsPasses === testsResultsSummary.itsTotal\n )\n\n if (allPassed) {\n out(chalk.mediumgreen(`${figures.tick}`))\n } else {\n out(chalk.mediumred(`${figures.cross}`))\n }\n\n // number of tests successful\n const testsText = `Tests: ${testsResultsSummary.itsPasses}/${testsResultsSummary.itsTotal}`\n if (testsResultsSummary.itsPasses === testsResultsSummary.itsTotal) {\n out(chalk.mediumgreen(`${testsText}`))\n } else {\n out(chalk.mediumred(`${testsText}`))\n }\n\n // number of items successful\n const describesText = `Items: ${testsResultsSummary.describesPasses}/${testsResultsSummary.describesTotal}`\n const invalidDescribesPlain = (testsResultsSummary.describesInvalid >= 1)\n ? (testsResultsSummary.describesInvalid === 1)\n ? '(+1 describe without tests)'\n : `(+${testsResultsSummary.describesInvalid} describes without tests)`\n : ''\n const describesThrownPlain = (describesThrownCount >= 1)\n ? (describesThrownCount === 1)\n ? '(1 describe errored)'\n : `(${describesThrownCount} describes errored)`\n : ''\n const describesDetailsText = [\n chalk.grey(invalidDescribesPlain), chalk.mediumred(describesThrownPlain)\n ]\n .filter(text => text !== '')\n .join(' ')\n const describesDetailsSuffix = describesDetailsText === '' ? '' : ` ${describesDetailsText}`\n if (testsResultsSummary.describesPasses === testsResultsSummary.describesTotal) {\n out(chalk.mediumgreen(`${describesText}`) + describesDetailsSuffix)\n } else {\n out(chalk.mediumred(`${describesText}`) + describesDetailsSuffix)\n }\n\n // number of test files successful\n const testFilesText = `Test Files: ${testsResultsSummary.passes}/${testsResultsSummary.total}`\n const invalidTestFilesPlain = (testsResultsSummary.invalid >= 1)\n ? (testsResultsSummary.invalid === 1)\n ? '(+1 file without tests)'\n : `(+${testsResultsSummary.invalid} files without tests)`\n : ''\n const failedToLoadPlain = (failedToLoadCount >= 1)\n ? (failedToLoadCount === 1)\n ? '(1 file failed to load, or errored)'\n : `(${failedToLoadCount} files failed to load, or errored)`\n : ''\n const testFilesDetailsText = [\n chalk.grey(invalidTestFilesPlain), chalk.mediumred(failedToLoadPlain)\n ]\n .filter(text => text !== '')\n .join(' ')\n const testFilesDetailsSuffix = testFilesDetailsText === '' ? '' : ` ${testFilesDetailsText}`\n if (testsResultsSummary.passes === testsResultsSummary.total) {\n out(chalk.mediumgreen(`${testFilesText}`) + testFilesDetailsSuffix)\n } else {\n out(chalk.mediumred(`${testFilesText}`) + testFilesDetailsSuffix)\n }\n\n // the tallies only cover what ran, so say the run was cut short - otherwise\n // \"Tests: 0/1\" reads as a one test suite\n const stoppedPlain = (stop.stopped)\n ? 'stopped at the first failure (failFast)'\n : ''\n if (stoppedPlain !== '') out(chalk.orange(stoppedPlain))\n\n const summaryLines = [\n testsText,\n joinPlain(describesText, invalidDescribesPlain, describesThrownPlain),\n joinPlain(testFilesText, invalidTestFilesPlain, failedToLoadPlain),\n ...(stoppedPlain === '') ? [] : [stoppedPlain]\n ]\n\n const durationMs = new Date().getTime() - runStartTime\n\n if (allPassed) {\n writeStatusFile(\n config, statusCodes.passed, 'all tests passed', summaryLines, durationMs\n )\n agentDone(\n config, agentRun, statusCodes.passed, 'all tests passed',\n testsResultsSummary, durationMs, state.failedTestFiles.size\n )\n } else {\n const abortedFiles = Object.keys(erroringTests)\n\n // a file that would not load, or a describe that threw, means the run died\n // partway - a different problem from tests that ran and failed\n const aborted = abortedFiles.length > 0 || describesThrownCount > 0\n const failedTestsCount = testsResultsSummary.itsTotal - testsResultsSummary.itsPasses\n\n const description = ([\n plural(abortedFiles.length, 'test file', 'failed to load or errored'),\n plural(describesThrownCount, 'describe', 'errored'),\n plural(failedTestsCount, 'test', 'failed')\n ].filter(part => part !== '').join(', ') || 'test run failed')\n + ((stop.stopped) ? ', stopped at the first failure' : '')\n\n const code = (aborted) ? statusCodes.aborted : statusCodes.failed\n const failures = failureEntries(Object.values(runTestResults), erroringTests)\n\n writeStatusFile(\n config,\n code,\n description,\n [...summaryLines, ...failureLines(Object.values(runTestResults), erroringTests)],\n durationMs\n )\n\n // failures first, so the done line is a complete end of run marker\n for (const failure of failures) agentFailure(config, agentRun, failure)\n agentDone(\n config, agentRun, code, description, testsResultsSummary, durationMs,\n state.failedTestFiles.size\n )\n }\n\n // full success?\n // true/false gets returned to the caller of runTests()\n return allPassed\n })\n } finally {\n if (reRunManager !== undefined) reRunManager.state.activeRuns--\n }\n}\n\n"]}
1
+ {"version":3,"file":"runTests.js","sourceRoot":"","sources":["../../../src/cli/lib/runTests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAK9D,OAAO,EAAE,mBAAmB,E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S,CAAC;QACP,IAAI,YAAY,KAAK,SAAS;YAAE,YAAY,CAAC,KAAK,CAAC,UAAU,EAAE,CAAA;IACnE,CAAC;AACL,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport chalk from '../../packages/chalk.js'\nimport { out as mainOut } from '../../output.js'\nimport figures from '../../packages/figures.js'\nimport { count } from 'sxy-lib/objects.js'\nimport { remove as arrayRemove } from 'sxy-lib/arrays.js'\nimport { allObj as promiseAllObj } from 'sxy-lib/promises.js'\n\nimport { loadTestFile } from './loadTestFile.js'\nimport { runTest } from './runTest.js'\nimport { showTestLoadingError } from './showTestLoadingError.js'\nimport { showTestResult } from './showTestResult.js'\nimport { failureLines } from './failureLines.js'\nimport { failureEntries } from './failureEntries.js'\nimport { agentDone, agentFailure, agentRunStart } from './agentReport.js'\nimport { makeStopSignal, stopIfFailFast } from './stopSignal.js'\nimport { statusCodes, writeStatusFile } from './statusFile.js'\n\nimport type {\n FinalConfig, OutFn, TestExecutionFilters, TestFile, TestResult, TestsResultsSummary\n} from '../../types.js'\nimport { makeRunManagerState, ReRunManageState } from './makeWatchRunState.js'\nimport { ReRunManager } from './reRunManager.js'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport type RunTestsPromise = Promise<boolean | null>\n\n// the summary lines, minus the colouring, for the status file\nfunction joinPlain(...parts: string[]): string {\n return parts.filter(part => part !== '').join(' ')\n}\n\nfunction plural(count: number, noun: string, verb: string): string {\n if (count < 1) return ''\n return `${count} ${noun}${count === 1 ? '' : 's'} ${verb}`\n}\n\nexport type Concurrency = {\n limit: number\n}\n\nexport async function runTests(\n config: FinalConfig,\n testFiles: Set<string>,\n reRunManager: ReRunManager | undefined,\n concurrency: Concurrency = { limit: -1 },\n refresh: 'refresh' | 'cached' = 'refresh',\n customOut?: OutFn,\n filters: TestExecutionFilters = {}\n): RunTestsPromise {\n if (reRunManager !== undefined) {\n reRunManager.state.lastTestFiles = new Set(testFiles)\n reRunManager.state.activeRuns++ // whatever, obsolete. Can use it to check on things\n }\n\n const state = reRunManager?.state || makeRunManagerState()\n const runStartTime = new Date().getTime()\n const agentRun = agentRunStart(config, testFiles.size)\n const stop = makeStopSignal()\n //console.log('new runTests:', watchRunState?.activeRuns)\n //console.log(inspect(testFiles))\n\n try {\n const testRunPromises: Record<string, Promise<TestResult>> = {}\n const erroringTests: Record<string, TestFile> = {}\n const testRunOutPromises: Record<string, Promise<void>> = {}\n\n await timeProfileAsync('run tests', async () => {\n if (Array.isArray(testFiles) ? testFiles.length > 0 : testFiles.size > 0) {\n for (const testFile of testFiles) {\n //console.log('testFiles', testFiles)\n //console.log('testFile', testFile)\n\n // an earlier file failed under failFast - leave the rest unloaded\n if (stop.stopped) break\n\n const test = await loadTestFile(config, testFile, refresh)\n\n if (test.error !== undefined && test.error !== false) {\n erroringTests[testFile] = test\n state.failedTestFiles.add(testFile)\n showTestLoadingError(config, test, customOut)\n stopIfFailFast(config, stop, true)\n } else {\n const testRunPromise = runTest(config, test, filters, stop)\n testRunPromises[testFile] = testRunPromise\n\n testRunOutPromises[testFile] = testRunPromise.then(async testResult => {\n if (testResult.success === true || testResult.success === null) {\n state.failedTestFiles.delete(testResult.file)\n } else {\n state.failedTestFiles.add(testFile)\n }\n const executionFilterActive = filters.describe !== undefined || filters.it !== undefined\n if (!executionFilterActive || testResult.describeResultsSummary.itsTotal > 0) {\n await showTestResult(config, testResult, customOut)\n }\n })\n\n // wait for the test to complete before proceeding if we are in 'sequential' mode\n if (config.execution.files === 'sequential') await testRunOutPromises[testFile]\n }\n }\n }\n })\n\n let runTestResults: Record<string, TestResult> = {}\n\n await timeProfileAsync('wait for tests to finish', async () => {\n runTestResults = await promiseAllObj(testRunPromises)\n\n // wait for the output to complete\n await promiseAllObj(testRunOutPromises)\n })\n\n return await timeProfileAsync('show initial test run results', () => {\n \n const out = customOut ?? mainOut\n\n const testsResultsSummary: TestsResultsSummary = {\n total: 0,\n passes: 0,\n invalid: 0,\n describesTotal: 0,\n describesPasses: 0,\n describesInvalid: 0,\n itsTotal: 0,\n itsPasses: 0\n // itsInvalid: 0 // we don't check whether tests run any asserts (we don't control the assertion lib)\n }\n let describesThrownCount = 0\n\n for (const testFile in runTestResults) {\n const runTestResult = runTestResults[testFile]\n if (!runTestResult) continue\n\n testsResultsSummary.total += +(runTestResult.success !== null)\n testsResultsSummary.passes += +(runTestResult.success ?? false)\n testsResultsSummary.invalid += +(runTestResult.success === null)\n testsResultsSummary.describesTotal += runTestResult.describeResultsSummary.total\n testsResultsSummary.describesPasses += runTestResult.describeResultsSummary.passes\n testsResultsSummary.describesInvalid += runTestResult.describeResultsSummary.invalid\n testsResultsSummary.itsTotal += runTestResult.describeResultsSummary.itsTotal\n testsResultsSummary.itsPasses += runTestResult.describeResultsSummary.itsPasses\n describesThrownCount += runTestResult.describeResults\n .filter(describeResult => describeResult.error !== undefined)\n .length\n }\n\n const failedToLoadCount = count(erroringTests)\n testsResultsSummary.total += failedToLoadCount\n\n if (\n (filters.describe !== undefined || filters.it !== undefined)\n && testsResultsSummary.itsTotal === 0\n && failedToLoadCount === 0\n && describesThrownCount === 0\n ) {\n out(chalk.orange('No tests matched the describe/test filters.'))\n const durationMs = new Date().getTime() - runStartTime\n writeStatusFile(\n config,\n statusCodes.couldNotRun,\n 'no tests matched the describe/test filters',\n [],\n durationMs\n )\n agentDone(\n config, agentRun, statusCodes.couldNotRun,\n 'no tests matched the describe/test filters', testsResultsSummary, durationMs,\n state.failedTestFiles.size\n )\n return null\n }\n\n out('\\n')\n\n const allPassed = (\n testsResultsSummary.passes === testsResultsSummary.total\n && testsResultsSummary.describesPasses === testsResultsSummary.describesTotal\n && testsResultsSummary.itsPasses === testsResultsSummary.itsTotal\n )\n\n if (allPassed) {\n out(chalk.mediumgreen(`${figures.tick}`))\n } else {\n out(chalk.mediumred(`${figures.cross}`))\n }\n\n // number of tests successful\n const testsText = `Tests: ${testsResultsSummary.itsPasses}/${testsResultsSummary.itsTotal}`\n if (testsResultsSummary.itsPasses === testsResultsSummary.itsTotal) {\n out(chalk.mediumgreen(`${testsText}`))\n } else {\n out(chalk.mediumred(`${testsText}`))\n }\n\n // number of items successful\n const describesText = `Items: ${testsResultsSummary.describesPasses}/${testsResultsSummary.describesTotal}`\n const invalidDescribesPlain = (testsResultsSummary.describesInvalid >= 1)\n ? (testsResultsSummary.describesInvalid === 1)\n ? '(+1 describe without tests)'\n : `(+${testsResultsSummary.describesInvalid} describes without tests)`\n : ''\n const describesThrownPlain = (describesThrownCount >= 1)\n ? (describesThrownCount === 1)\n ? '(1 describe errored)'\n : `(${describesThrownCount} describes errored)`\n : ''\n const describesDetailsText = [\n chalk.grey(invalidDescribesPlain), chalk.mediumred(describesThrownPlain)\n ]\n .filter(text => text !== '')\n .join(' ')\n const describesDetailsSuffix = describesDetailsText === '' ? '' : ` ${describesDetailsText}`\n if (testsResultsSummary.describesPasses === testsResultsSummary.describesTotal) {\n out(chalk.mediumgreen(`${describesText}`) + describesDetailsSuffix)\n } else {\n out(chalk.mediumred(`${describesText}`) + describesDetailsSuffix)\n }\n\n // number of test files successful\n const testFilesText = `Test Files: ${testsResultsSummary.passes}/${testsResultsSummary.total}`\n const invalidTestFilesPlain = (testsResultsSummary.invalid >= 1)\n ? (testsResultsSummary.invalid === 1)\n ? '(+1 file without tests)'\n : `(+${testsResultsSummary.invalid} files without tests)`\n : ''\n const failedToLoadPlain = (failedToLoadCount >= 1)\n ? (failedToLoadCount === 1)\n ? '(1 file failed to load, or errored)'\n : `(${failedToLoadCount} files failed to load, or errored)`\n : ''\n const testFilesDetailsText = [\n chalk.grey(invalidTestFilesPlain), chalk.mediumred(failedToLoadPlain)\n ]\n .filter(text => text !== '')\n .join(' ')\n const testFilesDetailsSuffix = testFilesDetailsText === '' ? '' : ` ${testFilesDetailsText}`\n if (testsResultsSummary.passes === testsResultsSummary.total) {\n out(chalk.mediumgreen(`${testFilesText}`) + testFilesDetailsSuffix)\n } else {\n out(chalk.mediumred(`${testFilesText}`) + testFilesDetailsSuffix)\n }\n\n // the tallies only cover what ran, so say the run was cut short - otherwise\n // \"Tests: 0/1\" reads as a one test suite\n const stoppedPlain = (stop.stopped)\n ? 'stopped at the first failure (failFast)'\n : ''\n if (stoppedPlain !== '') out(chalk.orange(stoppedPlain))\n\n const summaryLines = [\n testsText,\n joinPlain(describesText, invalidDescribesPlain, describesThrownPlain),\n joinPlain(testFilesText, invalidTestFilesPlain, failedToLoadPlain),\n ...(stoppedPlain === '') ? [] : [stoppedPlain]\n ]\n\n const durationMs = new Date().getTime() - runStartTime\n\n if (allPassed) {\n writeStatusFile(\n config, statusCodes.passed, 'all tests passed', summaryLines, durationMs\n )\n agentDone(\n config, agentRun, statusCodes.passed, 'all tests passed',\n testsResultsSummary, durationMs, state.failedTestFiles.size\n )\n } else {\n const abortedFiles = Object.keys(erroringTests)\n\n // a file that would not load, or a describe that threw, means the run died\n // partway - a different problem from tests that ran and failed\n const aborted = abortedFiles.length > 0 || describesThrownCount > 0\n const failedTestsCount = testsResultsSummary.itsTotal - testsResultsSummary.itsPasses\n\n const description = ([\n plural(abortedFiles.length, 'test file', 'failed to load or errored'),\n plural(describesThrownCount, 'describe', 'errored'),\n plural(failedTestsCount, 'test', 'failed')\n ].filter(part => part !== '').join(', ') || 'test run failed')\n + ((stop.stopped) ? ', stopped at the first failure' : '')\n\n const code = (aborted) ? statusCodes.aborted : statusCodes.failed\n const failures = failureEntries(Object.values(runTestResults), erroringTests)\n\n writeStatusFile(\n config,\n code,\n description,\n [...summaryLines, ...failureLines(Object.values(runTestResults), erroringTests)],\n durationMs\n )\n\n // failures first, so the done line is a complete end of run marker\n for (const failure of failures) agentFailure(config, agentRun, failure)\n agentDone(\n config, agentRun, code, description, testsResultsSummary, durationMs,\n state.failedTestFiles.size\n )\n }\n\n // full success?\n // true/false gets returned to the caller of runTests()\n return allPassed\n })\n } finally {\n if (reRunManager !== undefined) reRunManager.state.activeRuns--\n }\n}\n\n"]}
@@ -132,7 +132,7 @@ customOut, executionFilters = {}) {
132
132
  reRunManager.state.untestedFiles = new Set();
133
133
  debug('run tests on change');
134
134
  debug('toTest', toTest);
135
- return runTests(config, toTest, reRunManager, 'refresh', customOut, executionFilters);
135
+ return runTests(config, toTest, reRunManager, { limit: -1 }, 'refresh', customOut, executionFilters);
136
136
  });
137
137
  });
138
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"watchFilesAndRunTestsNodeWatch.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesAndRunTestsNodeWatch.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,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAQpC,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAElE,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAChD,MAAmB;AACnB,yBAAyB;AACzB,eAAgC,EAChC,YAAsB,EACtB,YAA0B;AAC1B,+BAA+B;AAC/B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5B,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;oCAEvB,OAAO,QAAQ,CACX,MAAM,EACN,MAAM,EACN,YAAY,EACZ,SAAS,EACT,SAAS,EACT,gBAAgB,CACnB,CAAA;gCACL,CAAC,CACJ,CAAA;4BACL,CAAC,CAAC,CAAA;wBACN,CAAC;oBACL,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACT,GAAG,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAA;oBACjC,CAAC;gBACL,CAAC,CAAC,CAAA;YACN,CAAC,EAAE,EAAE,CAAC,CAAA;QACV,CAAC,CAAC,qBAAqB;QAEvB,SAAS,UAAU,CAAC,QAAgB;YAChC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC3B,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;YAC5D,eAAe,CAAC,QAAQ,CAAC,GAAG,cAAc;iBACrC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;iBACrD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAA;QACpC,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,mFAAmF;IACnF,gFAAgF;IAChF,8EAA8E;IAC9E,qCAAqC;AACzC,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport chalk from '../../packages/chalk.js'\nimport minimatch from 'minimatch'\nimport slash from '../../packages/slash.js'\nimport { out as mainOut, log, debug } from '../../output.js'\n\nimport { agentChange } from './agentReport.js'\nimport { runTests } from './runTests.js'\nimport { buildDependencyTree } from './buildDependencyTree.js'\nimport { globArgCombine } from './globArgCombine.js'\nimport { addBasePath } from './addBasePath.js'\nimport { watchFilesNodeWatch } from './watchFilesNodeWatch.js'\nimport { filter } from './filter.js'\nimport { remove as arrayRemove } from 'sxy-lib/arrays.js'\n\nimport type { FinalConfig, DependencyTrees, OutFn, TestExecutionFilters } from '../../types.js'\nimport { ReRunManageState } from './makeWatchRunState.js'\nimport { ReRunManager } from './reRunManager.js'\nimport { inspect } from 'util'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport async function watchFilesAndRunTestsNodeWatch(\n config: FinalConfig,\n //testFiles: Set<string>,\n dependencyTrees: DependencyTrees,\n failingTests: string[],\n reRunManager: ReRunManager,\n //watchRunState: WatchRunState,\n customOut?: OutFn,\n executionFilters: TestExecutionFilters = {}\n): Promise<void> {\n const projectDir = process.cwd()\n // agent mode passes a sink here, so its own change lines are the only ones printed\n const out = customOut ?? mainOut\n\n await timeProfileAsync('init watching', async () => {\n debug('failingTests', failingTests)\n\n const testsGlobs = addBasePath(config.testsBase, config.tests)\n const testsIgnoreGlobs = addBasePath(config.testsBase, config.testsIgnore)\n\n // indentify a test file\n const testFilter = (file: string): boolean => {\n return minimatch(file, globArgCombine(testsGlobs))\n && !minimatch(file, globArgCombine(testsIgnoreGlobs))\n && (\n config.testsFilter === undefined\n || config.testsFilter === ''\n || filter(config.testsBase, config.testsFilter, file)\n )\n }\n\n let changedFiles: Array<[string, string]> = []\n let timeout: ReturnType<typeof setTimeout> | null = null\n\n if (config.watch.watchFilesBase === '') {\n out('No config.watch.watchFilesBase provided, defaulting to \\'.\\'')\n config.watch.watchFilesBase = '.'\n }\n\n await watchFilesNodeWatch(config, watchEvent)\n\n function watchEvent(filename: string, event: string): void {\n debug('handle watch event ', filename, event)\n\n filename = slash(filename)\n\n // remove dep tree for any tests that are deleted, avoiding trying to run it later\n if (event === 'remove') {\n debug('removing test', filename)\n if (filename in dependencyTrees) {\n reRunManager.state.allTestFiles.delete(filename)\n delete dependencyTrees[filename]\n } else if (!config.watch.dependencyEvaluation) {\n // without trees there is nothing to look the file up in\n reRunManager.state.allTestFiles.delete(filename)\n }\n }\n\n // info on the event found\n out(chalk.grey`change: ${filename} (${event})`)\n agentChange(config, filename, event)\n\n // add the file to changed files\n changedFiles.push([filename, event])\n\n // wait 100ms after any change before processing, to avoid multiple execution?\n if (timeout) {\n clearTimeout(timeout)\n }\n\n timeout = setTimeout(() => {\n void timeProfileAsync('handle changed files', async () => {\n debug('changedFiles', changedFiles)\n try {\n // build related test list\n //const tests: string[] = []\n const tests = new Set<string>\n for (const [file, fileEvent] of changedFiles) {\n debug('check', file)\n debug('1 tests', tests)\n if (fileEvent !== 'remove') { // only check if it's a test if it exists (has not just been removed)\n if (testFilter(file)) { // it is a test file itself, add to run list\n debug('its a test', file)\n //tests.push(file)\n tests.add(file)\n if (config.watch.dependencyEvaluation) {\n if (!(file in dependencyTrees)) { // if its a new test\n debug('try to add a new test', file)\n addNewTest(file)\n }\n } else {\n // no trees to record it in, so this is what makes a\n // newly created test part of the run set\n reRunManager.state.allTestFiles.add(file)\n }\n }\n }\n\n // with evaluation off there is nothing to map the change through:\n // any watched file could affect any test, so run the lot\n if (!config.watch.dependencyEvaluation) {\n for (const f of reRunManager.state.allTestFiles) tests.add(f)\n continue\n }\n\n debug('dtrees', dependencyTrees)\n debug('2 tests', tests)\n for (const f of Object.getOwnPropertyNames(dependencyTrees)) {\n debug('dep tree', f, dependencyTrees[f])\n if (dependencyTrees[f]?.some(dep => dep === file) === true) { // a test depends on this file\n debug('its a dependency', file)\n //tests.push(f)\n tests.add(f)\n }\n }\n }\n\n changedFiles = []\n\n debug('tests', tests)\n\n if (tests.size > 0) {\n await timeProfileAsync('build list of files to test and request a run', async () => {\n debug('tests', tests)\n debug('reRunFailingTests', config.watch.reRunFailingTests)\n\n // changes accumulate here because an 'auto' request made while a\n // run is in flight is coalesced into the queued one - everything\n // edited in the meantime still has to be covered\n reRunManager.state.untestedFiles\n = reRunManager.state.untestedFiles.union(tests)\n\n reRunManager.requestRun(\n 'auto',\n () => {\n // resolved when the run actually starts, not when it is\n // queued, so a coalesced request picks up the later edits\n const toTest = (config.watch.reRunFailingTests)\n ? reRunManager.state.untestedFiles\n .union(reRunManager.state.failedTestFiles)\n : new Set(reRunManager.state.untestedFiles)\n\n // consumed by this run - without this they are retested\n // on every later run for the rest of the session\n reRunManager.state.untestedFiles = new Set()\n\n debug('run tests on change')\n debug('toTest', toTest)\n\n return runTests(\n config,\n toTest,\n reRunManager,\n 'refresh',\n customOut,\n executionFilters\n )\n }\n )\n })\n }\n } catch (e) {\n log('watch handler error', e)\n }\n })\n }, 33)\n } // end of watch event\n\n function addNewTest(testFile: string): void {\n debug('new test', testFile)\n const dependencyTree = buildDependencyTree(config, testFile)\n dependencyTrees[testFile] = dependencyTree\n .map(file => slash(file).slice(projectDir.length + 1))\n .filter(f => f !== testFile)\n }\n })\n\n // NOTE: \"watching...\" is intentionally NOT printed here. watch() already emits it,\n // tied to a real milestone (the initial test run finishing, or no tests found).\n // Printing it again here produced a duplicate \"watching...\" on every startup.\n // out(chalk.brightblue`watching...`)\n}\n"]}
1
+ {"version":3,"file":"watchFilesAndRunTestsNodeWatch.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesAndRunTestsNodeWatch.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,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM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AC,CAAC,CAAA;IAEF,mFAAmF;IACnF,gFAAgF;IAChF,8EAA8E;IAC9E,qCAAqC;AACzC,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { showTimeProfiling } from '../../config.js'\nimport chalk from '../../packages/chalk.js'\nimport minimatch from 'minimatch'\nimport slash from '../../packages/slash.js'\nimport { out as mainOut, log, debug } from '../../output.js'\n\nimport { agentChange } from './agentReport.js'\nimport { runTests } from './runTests.js'\nimport { buildDependencyTree } from './buildDependencyTree.js'\nimport { globArgCombine } from './globArgCombine.js'\nimport { addBasePath } from './addBasePath.js'\nimport { watchFilesNodeWatch } from './watchFilesNodeWatch.js'\nimport { filter } from './filter.js'\nimport { remove as arrayRemove } from 'sxy-lib/arrays.js'\n\nimport type { FinalConfig, DependencyTrees, OutFn, TestExecutionFilters } from '../../types.js'\nimport { ReRunManageState } from './makeWatchRunState.js'\nimport { ReRunManager } from './reRunManager.js'\nimport { inspect } from 'util'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport async function watchFilesAndRunTestsNodeWatch(\n config: FinalConfig,\n //testFiles: Set<string>,\n dependencyTrees: DependencyTrees,\n failingTests: string[],\n reRunManager: ReRunManager,\n //watchRunState: WatchRunState,\n customOut?: OutFn,\n executionFilters: TestExecutionFilters = {}\n): Promise<void> {\n const projectDir = process.cwd()\n // agent mode passes a sink here, so its own change lines are the only ones printed\n const out = customOut ?? mainOut\n\n await timeProfileAsync('init watching', async () => {\n debug('failingTests', failingTests)\n\n const testsGlobs = addBasePath(config.testsBase, config.tests)\n const testsIgnoreGlobs = addBasePath(config.testsBase, config.testsIgnore)\n\n // indentify a test file\n const testFilter = (file: string): boolean => {\n return minimatch(file, globArgCombine(testsGlobs))\n && !minimatch(file, globArgCombine(testsIgnoreGlobs))\n && (\n config.testsFilter === undefined\n || config.testsFilter === ''\n || filter(config.testsBase, config.testsFilter, file)\n )\n }\n\n let changedFiles: Array<[string, string]> = []\n let timeout: ReturnType<typeof setTimeout> | null = null\n\n if (config.watch.watchFilesBase === '') {\n out('No config.watch.watchFilesBase provided, defaulting to \\'.\\'')\n config.watch.watchFilesBase = '.'\n }\n\n await watchFilesNodeWatch(config, watchEvent)\n\n function watchEvent(filename: string, event: string): void {\n debug('handle watch event ', filename, event)\n\n filename = slash(filename)\n\n // remove dep tree for any tests that are deleted, avoiding trying to run it later\n if (event === 'remove') {\n debug('removing test', filename)\n if (filename in dependencyTrees) {\n reRunManager.state.allTestFiles.delete(filename)\n delete dependencyTrees[filename]\n } else if (!config.watch.dependencyEvaluation) {\n // without trees there is nothing to look the file up in\n reRunManager.state.allTestFiles.delete(filename)\n }\n }\n\n // info on the event found\n out(chalk.grey`change: ${filename} (${event})`)\n agentChange(config, filename, event)\n\n // add the file to changed files\n changedFiles.push([filename, event])\n\n // wait 100ms after any change before processing, to avoid multiple execution?\n if (timeout) {\n clearTimeout(timeout)\n }\n\n timeout = setTimeout(() => {\n void timeProfileAsync('handle changed files', async () => {\n debug('changedFiles', changedFiles)\n try {\n // build related test list\n //const tests: string[] = []\n const tests = new Set<string>\n for (const [file, fileEvent] of changedFiles) {\n debug('check', file)\n debug('1 tests', tests)\n if (fileEvent !== 'remove') { // only check if it's a test if it exists (has not just been removed)\n if (testFilter(file)) { // it is a test file itself, add to run list\n debug('its a test', file)\n //tests.push(file)\n tests.add(file)\n if (config.watch.dependencyEvaluation) {\n if (!(file in dependencyTrees)) { // if its a new test\n debug('try to add a new test', file)\n addNewTest(file)\n }\n } else {\n // no trees to record it in, so this is what makes a\n // newly created test part of the run set\n reRunManager.state.allTestFiles.add(file)\n }\n }\n }\n\n // with evaluation off there is nothing to map the change through:\n // any watched file could affect any test, so run the lot\n if (!config.watch.dependencyEvaluation) {\n for (const f of reRunManager.state.allTestFiles) tests.add(f)\n continue\n }\n\n debug('dtrees', dependencyTrees)\n debug('2 tests', tests)\n for (const f of Object.getOwnPropertyNames(dependencyTrees)) {\n debug('dep tree', f, dependencyTrees[f])\n if (dependencyTrees[f]?.some(dep => dep === file) === true) { // a test depends on this file\n debug('its a dependency', file)\n //tests.push(f)\n tests.add(f)\n }\n }\n }\n\n changedFiles = []\n\n debug('tests', tests)\n\n if (tests.size > 0) {\n await timeProfileAsync('build list of files to test and request a run', async () => {\n debug('tests', tests)\n debug('reRunFailingTests', config.watch.reRunFailingTests)\n\n // changes accumulate here because an 'auto' request made while a\n // run is in flight is coalesced into the queued one - everything\n // edited in the meantime still has to be covered\n reRunManager.state.untestedFiles\n = reRunManager.state.untestedFiles.union(tests)\n\n reRunManager.requestRun(\n 'auto',\n () => {\n // resolved when the run actually starts, not when it is\n // queued, so a coalesced request picks up the later edits\n const toTest = (config.watch.reRunFailingTests)\n ? reRunManager.state.untestedFiles\n .union(reRunManager.state.failedTestFiles)\n : new Set(reRunManager.state.untestedFiles)\n\n // consumed by this run - without this they are retested\n // on every later run for the rest of the session\n reRunManager.state.untestedFiles = new Set()\n\n debug('run tests on change')\n debug('toTest', toTest)\n\n return runTests(\n config,\n toTest,\n reRunManager,\n { limit: -1 },\n 'refresh',\n customOut,\n executionFilters\n )\n }\n )\n })\n }\n } catch (e) {\n log('watch handler error', e)\n }\n })\n }, 33)\n } // end of watch event\n\n function addNewTest(testFile: string): void {\n debug('new test', testFile)\n const dependencyTree = buildDependencyTree(config, testFile)\n dependencyTrees[testFile] = dependencyTree\n .map(file => slash(file).slice(projectDir.length + 1))\n .filter(f => f !== testFile)\n }\n })\n\n // NOTE: \"watching...\" is intentionally NOT printed here. watch() already emits it,\n // tied to a real milestone (the initial test run finishing, or no tests found).\n // Printing it again here produced a duplicate \"watching...\" on every startup.\n // out(chalk.brightblue`watching...`)\n}\n"]}
package/dist/cli/once.js CHANGED
@@ -4,8 +4,9 @@ import { out, log } from '../output.js';
4
4
  import { setEnv } from './lib/setEnv.js';
5
5
  import { findingTestsMessage } from './lib/findingTestsMessage.js';
6
6
  import { foundTestsMessage } from './lib/foundTestsMessage.js';
7
- import { isTest } from './lib/isTest.js';
7
+ //import { isTest } from './lib/isTest.js'
8
8
  import { exitCodes } from './lib/exitCodes.js';
9
+ import { alwaysCacheBust } from './lib/alwaysCacheBust.js';
9
10
  export async function once() {
10
11
  const startTime = new Date().getTime();
11
12
  const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js');
@@ -112,11 +113,13 @@ export async function once() {
112
113
  process.exit(exitCodes.noTestFiles);
113
114
  }
114
115
  agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)));
116
+ const concurrency = { limit: -1 };
117
+ process.setSourceMapsEnabled(true); // enable source mapping
115
118
  // testFiles.size is guaranteed non-zero here - the no-tests case exited above
116
119
  const { runTests } = await import('./lib/runTests.js');
117
120
  if (!agentMode)
118
121
  log(chalk.brightblue `running tests...`);
119
- const testsResult = await runTests(config, testFiles, undefined, (isTest) ? 'refresh' : 'cached', runsOut, {
122
+ const testsResult = await runTests(config, testFiles, undefined, concurrency, (alwaysCacheBust) ? 'refresh' : 'cached', runsOut, {
120
123
  it: filterIt,
121
124
  describe: filterDescribe
122
125
  });
@@ -1 +1 @@
1
- {"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/cli/once.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,MAAM,CAAC,KAAK,UAAU,IAAI;IACtB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,C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KAAK,IAAI,CAAC;QACnC,CAAC,CAAC,SAAS,CAAC,eAAe;QAC3B,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAA;IAE7D,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAA,KAAK,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;IAEpD,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAClE,MAAM,cAAc,CAAC,MAAM,CAAC,CAAA;IAE5B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["\nimport chalk from '../packages/chalk.js'\n\nimport { packageName, configFileNames } from '../config.js'\nimport { out, log } from '../output.js'\n\nimport type { AllowedArguments, OutFn } from '../types.js'\nimport { setEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\nimport { isTest } from './lib/isTest.js'\nimport { exitCodes } from './lib/exitCodes.js'\n\n\nexport async function once(): Promise<void> {\n const startTime = new Date().getTime()\n\n const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js')\n const allowedClArguments: AllowedArguments = {\n config: {\n flag: 'c',\n hasValue: true\n },\n 'test-files': {\n flag: 't',\n hasValue: true\n },\n filter: {\n flag: 'f',\n hasValue: true\n },\n 'filter-it': {\n flag: 'i',\n hasValue: true\n },\n 'filter-describe': {\n flag: 'd',\n hasValue: true\n },\n 'fail-fast': {\n flag: 'x',\n hasValue: false\n },\n 'agent': {\n hasValue: false\n }\n }\n const clArguments = parseCommandLineArguments(allowedClArguments)\n //debug('clArguments', clArguments)\n\n // agent mode owns stdout: the usual per-test output is routed into a sink, leaving the\n // failures and the summary. Announced before the config loads, as in watch mode.\n const agentMode = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentSetRunReason, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentMode)\n agentSetRunReason('once')\n const agentOut: OutFn = (agentMode) ? agentSilentOut : out\n const runsOut = (agentMode) ? agentSilentOut : undefined\n\n agentOut(chalk.brightblue`[${packageName}]...`)\n\n setEnv()\n\n const { loadConfig } = await import('./lib/loadConfig.js')\n const userConfig = (typeof clArguments.config === 'string')\n ? await loadConfig(clArguments.config)\n : await loadConfig()\n\n if ('test-files' in clArguments) {\n const testFilesPattern = clArguments['test-files']\n if (typeof testFilesPattern !== 'string' || testFilesPattern === '') {\n throw new Error('No pattern specified for --test-files or -t argument')\n }\n //console.log('Looking for tests using pattern: ' + testFilesPattern) // eslint-disable-line no-console\n userConfig.tests = testFilesPattern\n }\n\n if ('filter' in clArguments) {\n const filter = clArguments.filter\n if (typeof filter !== 'string' || filter === '') {\n throw new Error('No pattern specified for --filter or -f argument')\n }\n //console.log('Filtering tests using pattern: ' + filter) // eslint-disable-line no-console\n userConfig.testsFilter = filter\n }\n\n const filterIt = clArguments['filter-it']\n const filterDescribe = clArguments['filter-describe']\n if (filterIt === true || filterIt === '') throw new Error('No substring specified for --filter-it')\n if (filterDescribe === true || filterDescribe === '') {\n throw new Error('No substring specified for --filter-describe')\n }\n\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\n const config = applyConfigDefaults(userConfig)\n // both flags are the only source: assigned rather than or'd, so a config file cannot\n // silently truncate every run, or swap the output format out from under a caller\n config.failFast = clArguments['fail-fast'] === true\n config.watch.agent = agentMode\n\n const { validateConfig } = await import('./lib/validateConfig.js')\n validateConfig(config)\n\n //console.log('run setup')\n //console.log(util.inspect(config))\n const { doUserSetup } = await import('./lib/doUserSetup.js')\n await doUserSetup(config, agentOut)\n //console.log('ran setup')\n \n agentOut(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n agentFound(config, testFiles.size)\n\n if (testFiles.size === 0) {\n agentOut(chalk.mediumred(`[${packageName}] Found no tests.`\n + '\\nCreate tests matching the patterns, '\n + `\\nor set new patterns in ${configFileNames.map(x => `${x}.js/cjs/mjs`).join(' or ')}`))\n\n const endTime = new Date().getTime()\n const time = endTime - startTime\n agentOut(chalk.brightblue(`[${packageName}] time: ${time.toLocaleString()}ms`))\n\n // reported as a run, so a reader waiting on a done line always gets one\n const { statusCodes } = await import('./lib/statusFile.js')\n const run = agentRunStart(config, 0)\n agentDone(config, run, statusCodes.couldNotRun, 'no test files found', null, time, 0)\n\n // setup has already run by this point, so teardown must run too, or its side\n // effects are left behind\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(exitCodes.noTestFiles)\n }\n\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n // testFiles.size is guaranteed non-zero here - the no-tests case exited above\n const { runTests } = await import('./lib/runTests.js')\n if (!agentMode) log(chalk.brightblue`running tests...`)\n const testsResult = await runTests(\n config, testFiles,\n undefined,\n (isTest) ? 'refresh' : 'cached',\n runsOut,\n {\n it: filterIt,\n describe: filterDescribe\n }\n )\n // a distinct code from noTestFiles, so callers can tell \"no test file matched the\n // pattern\" from \"the files matched but the filters selected nothing in them\"\n const exitCode = (testsResult === null)\n ? exitCodes.noMatchingTests\n : (testsResult) ? exitCodes.passed : exitCodes.testErrors\n\n const time = new Date().getTime() - startTime\n agentOut(chalk.grey`\\n${time.toLocaleString()}ms\\n`)\n\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(exitCode)\n}\n"]}
1
+ {"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/cli/once.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,sBAAsB,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAA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AAE,CAAA;IAE9C,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA,CAAC,wBAAwB;IAE3D,8EAA8E;IAC9E,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAA;IACtD,IAAI,CAAC,SAAS;QAAE,GAAG,CAAC,KAAK,CAAC,UAAU,CAAA,kBAAkB,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,MAAM,QAAQ,CAC9B,MAAM,EAAE,SAAS,EACjB,SAAS,EACT,WAAW,EACX,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACxC,OAAO,EACP;QACI,EAAE,EAAE,QAAQ;QACZ,QAAQ,EAAE,cAAc;KAC3B,CACJ,CAAA;IACD,kFAAkF;IAClF,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,CAAC,WAAW,KAAK,IAAI,CAAC;QACnC,CAAC,CAAC,SAAS,CAAC,eAAe;QAC3B,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAA;IAE7D,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAA,KAAK,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;IAEpD,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAClE,MAAM,cAAc,CAAC,MAAM,CAAC,CAAA;IAE5B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["\nimport chalk from '../packages/chalk.js'\n\nimport { packageName, configFileNames } from '../config.js'\nimport { out, log } from '../output.js'\n\nimport type { AllowedArguments, OutFn } from '../types.js'\nimport { setEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\n//import { isTest } from './lib/isTest.js'\nimport { exitCodes } from './lib/exitCodes.js'\nimport { envFlag } from '../envFlag.js'\nimport { alwaysCacheBust } from './lib/alwaysCacheBust.js'\nimport { Concurrency } from './lib/runTests.js'\n\n\nexport async function once(): Promise<void> {\n const startTime = new Date().getTime()\n\n const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js')\n const allowedClArguments: AllowedArguments = {\n config: {\n flag: 'c',\n hasValue: true\n },\n 'test-files': {\n flag: 't',\n hasValue: true\n },\n filter: {\n flag: 'f',\n hasValue: true\n },\n 'filter-it': {\n flag: 'i',\n hasValue: true\n },\n 'filter-describe': {\n flag: 'd',\n hasValue: true\n },\n 'fail-fast': {\n flag: 'x',\n hasValue: false\n },\n 'agent': {\n hasValue: false\n }\n }\n const clArguments = parseCommandLineArguments(allowedClArguments)\n //debug('clArguments', clArguments)\n\n // agent mode owns stdout: the usual per-test output is routed into a sink, leaving the\n // failures and the summary. Announced before the config loads, as in watch mode.\n const agentMode = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentSetRunReason, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentMode)\n agentSetRunReason('once')\n const agentOut: OutFn = (agentMode) ? agentSilentOut : out\n const runsOut = (agentMode) ? agentSilentOut : undefined\n\n agentOut(chalk.brightblue`[${packageName}]...`)\n\n setEnv()\n\n const { loadConfig } = await import('./lib/loadConfig.js')\n const userConfig = (typeof clArguments.config === 'string')\n ? await loadConfig(clArguments.config)\n : await loadConfig()\n\n if ('test-files' in clArguments) {\n const testFilesPattern = clArguments['test-files']\n if (typeof testFilesPattern !== 'string' || testFilesPattern === '') {\n throw new Error('No pattern specified for --test-files or -t argument')\n }\n //console.log('Looking for tests using pattern: ' + testFilesPattern) // eslint-disable-line no-console\n userConfig.tests = testFilesPattern\n }\n\n if ('filter' in clArguments) {\n const filter = clArguments.filter\n if (typeof filter !== 'string' || filter === '') {\n throw new Error('No pattern specified for --filter or -f argument')\n }\n //console.log('Filtering tests using pattern: ' + filter) // eslint-disable-line no-console\n userConfig.testsFilter = filter\n }\n\n const filterIt = clArguments['filter-it']\n const filterDescribe = clArguments['filter-describe']\n if (filterIt === true || filterIt === '') throw new Error('No substring specified for --filter-it')\n if (filterDescribe === true || filterDescribe === '') {\n throw new Error('No substring specified for --filter-describe')\n }\n\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\n const config = applyConfigDefaults(userConfig)\n // both flags are the only source: assigned rather than or'd, so a config file cannot\n // silently truncate every run, or swap the output format out from under a caller\n config.failFast = clArguments['fail-fast'] === true\n config.watch.agent = agentMode\n\n const { validateConfig } = await import('./lib/validateConfig.js')\n validateConfig(config)\n\n //console.log('run setup')\n //console.log(util.inspect(config))\n const { doUserSetup } = await import('./lib/doUserSetup.js')\n await doUserSetup(config, agentOut)\n //console.log('ran setup')\n \n agentOut(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n agentFound(config, testFiles.size)\n\n if (testFiles.size === 0) {\n agentOut(chalk.mediumred(`[${packageName}] Found no tests.`\n + '\\nCreate tests matching the patterns, '\n + `\\nor set new patterns in ${configFileNames.map(x => `${x}.js/cjs/mjs`).join(' or ')}`))\n\n const endTime = new Date().getTime()\n const time = endTime - startTime\n agentOut(chalk.brightblue(`[${packageName}] time: ${time.toLocaleString()}ms`))\n\n // reported as a run, so a reader waiting on a done line always gets one\n const { statusCodes } = await import('./lib/statusFile.js')\n const run = agentRunStart(config, 0)\n agentDone(config, run, statusCodes.couldNotRun, 'no test files found', null, time, 0)\n\n // setup has already run by this point, so teardown must run too, or its side\n // effects are left behind\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(exitCodes.noTestFiles)\n }\n\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n const concurrency: Concurrency = { limit: -1 }\n\n process.setSourceMapsEnabled(true) // enable source mapping\n \n // testFiles.size is guaranteed non-zero here - the no-tests case exited above\n const { runTests } = await import('./lib/runTests.js')\n if (!agentMode) log(chalk.brightblue`running tests...`)\n const testsResult = await runTests(\n config, testFiles,\n undefined,\n concurrency,\n (alwaysCacheBust) ? 'refresh' : 'cached',\n runsOut,\n {\n it: filterIt,\n describe: filterDescribe\n }\n )\n // a distinct code from noTestFiles, so callers can tell \"no test file matched the\n // pattern\" from \"the files matched but the filters selected nothing in them\"\n const exitCode = (testsResult === null)\n ? exitCodes.noMatchingTests\n : (testsResult) ? exitCodes.passed : exitCodes.testErrors\n\n const time = new Date().getTime() - startTime\n agentOut(chalk.grey`\\n${time.toLocaleString()}ms\\n`)\n\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n await doUserTeardown(config)\n\n process.exit(exitCode)\n}\n"]}
package/dist/cli/watch.js CHANGED
@@ -4,9 +4,10 @@ import { out, debug } from '../output.js';
4
4
  import { setEnv } from './lib/setEnv.js';
5
5
  import { findingTestsMessage } from './lib/findingTestsMessage.js';
6
6
  import { foundTestsMessage } from './lib/foundTestsMessage.js';
7
- import { isTest } from './lib/isTest.js';
7
+ //import { isTest } from './lib/isTest.js'
8
8
  import { makeRunManagerState } from './lib/makeWatchRunState.js';
9
9
  import { makeReRunManager } from './lib/reRunManager.js';
10
+ import { alwaysCacheBust } from './lib/alwaysCacheBust.js';
10
11
  export async function watch() {
11
12
  const startTime = new Date().getTime();
12
13
  const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js');
@@ -117,10 +118,12 @@ export async function watch() {
117
118
  let dependencyTrees = {};
118
119
  // store failing tests so we can re-run them.
119
120
  const failingTests = [];
121
+ const concurrency = { limit: -1 };
120
122
  const reRunManager = makeReRunManager(null, makeRunManagerState({
121
123
  allTestFiles: testFiles,
122
124
  lastTestFiles: testFiles
123
125
  }), runsOut);
126
+ process.setSourceMapsEnabled(true); // enable source mapping
124
127
  const { runTests } = await import('./lib/runTests.js');
125
128
  let initialTestRun = null;
126
129
  if (testFiles.size > 0) {
@@ -134,7 +137,7 @@ export async function watch() {
134
137
  }
135
138
  if (config.watch.runAllOnStartup) {
136
139
  agentOut(chalk.brightblue `running initial tests...`);
137
- initialTestRun = runTests(config, testFiles, reRunManager, (isTest) ? 'refresh' : 'cached', runsOut, executionFilters).then(async (testsResult) => {
140
+ initialTestRun = runTests(config, testFiles, reRunManager, concurrency, (alwaysCacheBust) ? 'refresh' : 'cached', runsOut, executionFilters).then(async (testsResult) => {
138
141
  const time = new Date().getTime() - startTime;
139
142
  //await new Promise((resolve) => setTimeout(resolve, 100))
140
143
  agentOut(chalk.grey `\n${time.toLocaleString()}ms`);
@@ -163,7 +166,7 @@ export async function watch() {
163
166
  agentWatching(config, testFiles.size);
164
167
  const { listenToUser } = await import('./lib/listenToUser.js');
165
168
  listenToUser(reRunManager, files => () => {
166
- return runTests(config, files, reRunManager, 'refresh', runsOut, executionFilters);
169
+ return runTests(config, files, reRunManager, concurrency, 'refresh', runsOut, executionFilters);
167
170
  }, config.watch.ttyActionsOnKeypress, initialTestRun, process.stdin, runsOut).catch(e => { throw e; });
168
171
  // park forever - watch mode ends by being signalled, and the shutdown handlers registered
169
172
  // above run the user's teardown on the way out
@@ -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,i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E;QAC9E,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;QACpC,SAAS,CACL,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC,WAAW,EAAE,qBAAqB,EAC3D,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC,CAC5C,CAAA;IACL,CAAC;IAED,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,MAAM,CAAC,gCAAgC,CAAC,CAAA;IAChF,MAAM,qBAAqB,CACvB,MAAM;IACN,YAAY;IACZ,eAAe,EACf,YAAY,EAAE,qCAAqC;IACnD,YAAY;IACZ,gBAAgB;IAChB,OAAO,EACP,gBAAgB,CACnB,CAAA;IAGD,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAA,aAAa,CAAC,CAAA;IACvC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;IAErC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAA;IAC9D,YAAY,CACR,YAAY,EACZ,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE;QACV,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;IACtF,CAAC,EACD,MAAM,CAAC,KAAK,CAAC,oBAAoB,EACjC,cAAc,EACd,OAAO,CAAC,KAAK,EACb,OAAO,CACV,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;IAGzB,0FAA0F;IAC1F,+CAA+C;IAC/C,MAAM,IAAI,OAAO,CAAO,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;AACrC,CAAC","sourcesContent":["import chalk from '../packages/chalk.js'\n\nimport { packageName } from '../config.js'\nimport { out, debug } from '../output.js'\n\nimport type { AllowedArguments, DependencyTrees, OutFn } from '../types.js'\nimport { setEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\nimport { isTest } from './lib/isTest.js'\nimport { makeRunManagerState } from './lib/makeWatchRunState.js'\nimport { makeReRunManager } from './lib/reRunManager.js'\n\nexport async function watch(): Promise<void> {\n const startTime = new Date().getTime()\n\n const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js')\n const allowedClArguments: AllowedArguments = {\n 'config': {\n flag: 'c',\n hasValue: true\n },\n 'test-files': {\n flag: 't',\n hasValue: true\n },\n 'filter': {\n flag: 'f',\n hasValue: true\n },\n 'filter-it': {\n flag: 'i',\n hasValue: true\n },\n 'filter-describe': {\n flag: 'd',\n hasValue: true\n },\n 'status-file': {\n flag: 's',\n hasValue: true\n },\n 'agent': {\n hasValue: false\n }\n }\n const clArguments = parseCommandLineArguments(allowedClArguments)\n //debug('clArguments', clArguments)\n\n // agent mode owns stdout, so the banner and every later message below is routed through\n // agentOut - a sink when the flag is on. Announced before the config loads, so a reader\n // sees the process is alive even if startup is slow.\n const agentMode = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentWatching, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentMode)\n const agentOut: OutFn = (agentMode) ? agentSilentOut : out\n const runsOut = (agentMode) ? agentSilentOut : undefined\n\n agentOut(chalk.brightblue`[${packageName}]...`)\n\n setEnv()\n\n const { loadConfig } = await import('./lib/loadConfig.js')\n const userConfig = (typeof clArguments.config === 'string')\n ? await loadConfig(clArguments.config)\n : await loadConfig()\n\n if ('test-files' in clArguments) {\n const testFilesPattern = clArguments['test-files']\n if (typeof testFilesPattern !== 'string' || testFilesPattern === '') {\n throw new Error('No pattern specified for --test-files or -t argument')\n }\n userConfig.tests = testFilesPattern\n }\n\n if ('filter' in clArguments) {\n const filter = clArguments.filter\n if (typeof filter !== 'string' || filter === '') {\n throw new Error('No pattern specified for --filter or -f argument')\n }\n userConfig.testsFilter = filter\n }\n\n if ('status-file' in clArguments) {\n const statusFile = clArguments['status-file']\n if (typeof statusFile !== 'string' || statusFile === '') {\n throw new Error('No file path specified for --status-file or -s argument')\n }\n userConfig.watch = { ...userConfig.watch, statusFile }\n }\n\n const filterIt = clArguments['filter-it']\n const filterDescribe = clArguments['filter-describe']\n if (filterIt === true || filterIt === '') throw new Error('No substring specified for --filter-it')\n if (filterDescribe === true || filterDescribe === '') {\n throw new Error('No substring specified for --filter-describe')\n }\n const executionFilters = { it: filterIt, describe: filterDescribe }\n\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\n const config = applyConfigDefaults(userConfig)\n if (agentMode) config.watch.agent = true\n // there is no watch flag for it, and a config file must not enable it here: a truncated\n // run would still report covers=all, and failing files would drop out of `failing`\n config.failFast = false\n\n // not silenced in agent mode - a config error is fatal, so losing the message is worse\n // than breaking the one-line-per-event contract\n const { validateConfig } = await import('./lib/validateConfig.js')\n validateConfig(config)\n\n // no run has finished yet, so the status file starts at -1 rather than stale\n const { resetStatusFile, statusCodes, writeStatusFile } = await import('./lib/statusFile.js')\n resetStatusFile(config)\n\n const { doUserSetup } = await import('./lib/doUserSetup.js')\n await doUserSetup(config, agentOut)\n\n // watch mode never reaches an end of its own, so teardown only gets a chance on the way\n // out. Registered here so it pairs with the setup above and covers the initial run too.\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n const { registerShutdownHandlers } = await import('./lib/shutdown.js')\n registerShutdownHandlers(config, {\n teardown: doUserTeardown,\n exit: code => process.exit(code)\n })\n\n agentOut(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n debug(testFiles)\n agentFound(config, testFiles.size)\n\n // global store of the dependencies of tests\n let dependencyTrees: DependencyTrees = {}\n // store failing tests so we can re-run them.\n const failingTests: string[] = []\n \n const reRunManager = makeReRunManager(\n null,\n makeRunManagerState({\n allTestFiles: testFiles,\n lastTestFiles: testFiles\n }),\n runsOut\n )\n\n const { runTests } = await import('./lib/runTests.js')\n let initialTestRun: Promise<boolean | null> | null = null\n\n if (testFiles.size > 0) {\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n // the trees are only consulted to narrow a run, so with evaluation off building them\n // is pure cost - and it is the slowest part of startup on a large suite\n if (config.watch.dependencyEvaluation) {\n const { buildDependencyTrees } = await import('./lib/buildDependencyTrees.js')\n agentOut(chalk.brightblue`finding initial dependency trees...`)\n dependencyTrees = await buildDependencyTrees(config, testFiles)\n }\n\n if (config.watch.runAllOnStartup) {\n agentOut(chalk.brightblue`running initial tests...`)\n initialTestRun = runTests(\n config, testFiles, reRunManager,\n (isTest) ? 'refresh' : 'cached',\n runsOut, executionFilters\n ).then(async testsResult => {\n const time = new Date().getTime() - startTime\n //await new Promise((resolve) => setTimeout(resolve, 100))\n agentOut(chalk.grey`\\n${time.toLocaleString()}ms`)\n return testsResult\n })\n reRunManager.state.currentRun = initialTestRun\n // do we need to catch errors like this?\n initialTestRun.catch(err => `Error during initial test run: ${err}`)\n }\n } else {\n agentOut(chalk.orange`no test files found`)\n writeStatusFile(config, statusCodes.couldNotRun, 'no test files found')\n // still reported as a run, so a reader waiting on a done line always gets one\n const run = agentRunStart(config, 0)\n agentDone(\n config, run, statusCodes.couldNotRun, 'no test files found',\n null, new Date().getTime() - startTime, 0\n )\n }\n\n const { watchFilesAndRunTests } = await import('./lib/watchFilesAndRunTests.js')\n await watchFilesAndRunTests(\n config,\n //testFiles,\n dependencyTrees,\n failingTests, // CHECK this should also be in state\n reRunManager,\n //watchRunState,\n runsOut,\n executionFilters\n )\n\n\n agentOut(chalk.brightblue`watching...`)\n agentWatching(config, testFiles.size)\n\n const { listenToUser } = await import('./lib/listenToUser.js')\n listenToUser(\n reRunManager,\n files => () => {\n return runTests(config, files, reRunManager, 'refresh', runsOut, executionFilters)\n },\n config.watch.ttyActionsOnKeypress,\n initialTestRun,\n process.stdin,\n runsOut\n ).catch(e => { throw e })\n\n\n // park forever - watch mode ends by being signalled, and the shutdown handlers registered\n // above run the user's teardown on the way out\n await new Promise<void>(() => {})\n}\n"]}
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,0CAA0C;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,MAAM,CAAC,KAAK,UAAU,KAAK;IACvB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAEtC,MAAM,EAAE,yBAAyB,EAAE,GAAG,MAAM,MAAM,CAAC,oCAAoC,CAAC,CAAA;IACxF,MAAM,kBAAkB,GAAqB;QACzC,QAAQ,EAAE;YACN,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,YAAY,EAAE;YACV,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,QAAQ,EAAE;YACN,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,WAAW,EAAE;YACT,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,iBAAiB,EAAE;YACf,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACjB;QACD,aAAa,EAAE;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,SAAS,CAAC,IAAI,CAAC,CAAA;IAErC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAA;IAC9D,YAAY,CACR,YAAY,EACZ,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE;QACV,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;IACnG,CAAC,EACD,MAAM,CAAC,KAAK,CAAC,oBAAoB,EACjC,cAAc,EACd,OAAO,CAAC,KAAK,EACb,OAAO,CACV,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;IAGzB,0FAA0F;IAC1F,+CAA+C;IAC/C,MAAM,IAAI,OAAO,CAAO,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;AACrC,CAAC","sourcesContent":["import chalk from '../packages/chalk.js'\n\nimport { packageName } from '../config.js'\nimport { out, debug } from '../output.js'\n\nimport type { AllowedArguments, DependencyTrees, OutFn } from '../types.js'\nimport { setEnv } from './lib/setEnv.js'\nimport { findingTestsMessage } from './lib/findingTestsMessage.js'\nimport { foundTestsMessage } from './lib/foundTestsMessage.js'\n//import { isTest } from './lib/isTest.js'\nimport { makeRunManagerState } from './lib/makeWatchRunState.js'\nimport { makeReRunManager } from './lib/reRunManager.js'\nimport { alwaysCacheBust } from './lib/alwaysCacheBust.js'\nimport { Concurrency } from './lib/runTests.js'\n\nexport async function watch(): Promise<void> {\n const startTime = new Date().getTime()\n\n const { parseCommandLineArguments } = await import('./lib/parseCommandLineArguments.js')\n const allowedClArguments: AllowedArguments = {\n 'config': {\n flag: 'c',\n hasValue: true\n },\n 'test-files': {\n flag: 't',\n hasValue: true\n },\n 'filter': {\n flag: 'f',\n hasValue: true\n },\n 'filter-it': {\n flag: 'i',\n hasValue: true\n },\n 'filter-describe': {\n flag: 'd',\n hasValue: true\n },\n 'status-file': {\n flag: 's',\n hasValue: true\n },\n 'agent': {\n hasValue: false\n }\n }\n const clArguments = parseCommandLineArguments(allowedClArguments)\n //debug('clArguments', clArguments)\n\n // agent mode owns stdout, so the banner and every later message below is routed through\n // agentOut - a sink when the flag is on. Announced before the config loads, so a reader\n // sees the process is alive even if startup is slow.\n const agentMode = clArguments.agent === true\n const {\n agentInit, agentFound, agentRunStart, agentDone, agentWatching, agentSilentOut\n } = await import('./lib/agentReport.js')\n agentInit(agentMode)\n const agentOut: OutFn = (agentMode) ? agentSilentOut : out\n const runsOut = (agentMode) ? agentSilentOut : undefined\n\n agentOut(chalk.brightblue`[${packageName}]...`)\n\n setEnv()\n\n const { loadConfig } = await import('./lib/loadConfig.js')\n const userConfig = (typeof clArguments.config === 'string')\n ? await loadConfig(clArguments.config)\n : await loadConfig()\n\n if ('test-files' in clArguments) {\n const testFilesPattern = clArguments['test-files']\n if (typeof testFilesPattern !== 'string' || testFilesPattern === '') {\n throw new Error('No pattern specified for --test-files or -t argument')\n }\n userConfig.tests = testFilesPattern\n }\n\n if ('filter' in clArguments) {\n const filter = clArguments.filter\n if (typeof filter !== 'string' || filter === '') {\n throw new Error('No pattern specified for --filter or -f argument')\n }\n userConfig.testsFilter = filter\n }\n\n if ('status-file' in clArguments) {\n const statusFile = clArguments['status-file']\n if (typeof statusFile !== 'string' || statusFile === '') {\n throw new Error('No file path specified for --status-file or -s argument')\n }\n userConfig.watch = { ...userConfig.watch, statusFile }\n }\n\n const filterIt = clArguments['filter-it']\n const filterDescribe = clArguments['filter-describe']\n if (filterIt === true || filterIt === '') throw new Error('No substring specified for --filter-it')\n if (filterDescribe === true || filterDescribe === '') {\n throw new Error('No substring specified for --filter-describe')\n }\n const executionFilters = { it: filterIt, describe: filterDescribe }\n\n const { applyConfigDefaults } = await import('./lib/applyConfigDefaults.js')\n const config = applyConfigDefaults(userConfig)\n if (agentMode) config.watch.agent = true\n // there is no watch flag for it, and a config file must not enable it here: a truncated\n // run would still report covers=all, and failing files would drop out of `failing`\n config.failFast = false\n\n // not silenced in agent mode - a config error is fatal, so losing the message is worse\n // than breaking the one-line-per-event contract\n const { validateConfig } = await import('./lib/validateConfig.js')\n validateConfig(config)\n\n // no run has finished yet, so the status file starts at -1 rather than stale\n const { resetStatusFile, statusCodes, writeStatusFile } = await import('./lib/statusFile.js')\n resetStatusFile(config)\n\n const { doUserSetup } = await import('./lib/doUserSetup.js')\n await doUserSetup(config, agentOut)\n\n // watch mode never reaches an end of its own, so teardown only gets a chance on the way\n // out. Registered here so it pairs with the setup above and covers the initial run too.\n const { doUserTeardown } = await import('./lib/doUserTeardown.js')\n const { registerShutdownHandlers } = await import('./lib/shutdown.js')\n registerShutdownHandlers(config, {\n teardown: doUserTeardown,\n exit: code => process.exit(code)\n })\n\n agentOut(chalk.brightblue(findingTestsMessage(config)))\n const { findTestFiles } = await import('./lib/findTestFiles.js')\n const testFiles = await findTestFiles(config)\n debug(testFiles)\n agentFound(config, testFiles.size)\n\n // global store of the dependencies of tests\n let dependencyTrees: DependencyTrees = {}\n // store failing tests so we can re-run them.\n const failingTests: string[] = []\n \n const concurrency: Concurrency = { limit: -1 }\n\n const reRunManager = makeReRunManager(\n null,\n makeRunManagerState({\n allTestFiles: testFiles,\n lastTestFiles: testFiles\n }),\n runsOut\n )\n\n process.setSourceMapsEnabled(true) // enable source mapping\n\n const { runTests } = await import('./lib/runTests.js')\n let initialTestRun: Promise<boolean | null> | null = null\n if (testFiles.size > 0) {\n agentOut(chalk.brightblue(foundTestsMessage(testFiles.size)))\n\n // the trees are only consulted to narrow a run, so with evaluation off building them\n // is pure cost - and it is the slowest part of startup on a large suite\n if (config.watch.dependencyEvaluation) {\n const { buildDependencyTrees } = await import('./lib/buildDependencyTrees.js')\n agentOut(chalk.brightblue`finding initial dependency trees...`)\n dependencyTrees = await buildDependencyTrees(config, testFiles)\n }\n\n if (config.watch.runAllOnStartup) {\n agentOut(chalk.brightblue`running initial tests...`)\n initialTestRun = runTests(\n config, testFiles,\n reRunManager,\n concurrency,\n (alwaysCacheBust) ? 'refresh' : 'cached',\n runsOut, executionFilters\n ).then(async testsResult => {\n const time = new Date().getTime() - startTime\n //await new Promise((resolve) => setTimeout(resolve, 100))\n agentOut(chalk.grey`\\n${time.toLocaleString()}ms`)\n return testsResult\n })\n reRunManager.state.currentRun = initialTestRun\n // do we need to catch errors like this?\n initialTestRun.catch(err => `Error during initial test run: ${err}`)\n }\n } else {\n agentOut(chalk.orange`no test files found`)\n writeStatusFile(config, statusCodes.couldNotRun, 'no test files found')\n // still reported as a run, so a reader waiting on a done line always gets one\n const run = agentRunStart(config, 0)\n agentDone(\n config, run, statusCodes.couldNotRun, 'no test files found',\n null, new Date().getTime() - startTime, 0\n )\n }\n\n const { watchFilesAndRunTests } = await import('./lib/watchFilesAndRunTests.js')\n await watchFilesAndRunTests(\n config,\n //testFiles,\n dependencyTrees,\n failingTests, // CHECK this should also be in state\n reRunManager,\n //watchRunState,\n runsOut,\n executionFilters\n )\n\n\n agentOut(chalk.brightblue`watching...`)\n agentWatching(config, testFiles.size)\n\n const { listenToUser } = await import('./lib/listenToUser.js')\n listenToUser(\n reRunManager,\n files => () => {\n return runTests(config, files, reRunManager, concurrency, 'refresh', runsOut, executionFilters)\n },\n config.watch.ttyActionsOnKeypress,\n initialTestRun,\n process.stdin,\n runsOut\n ).catch(e => { throw e })\n\n\n // park forever - watch mode ends by being signalled, and the shutdown handlers registered\n // above run the user's teardown on the way out\n await new Promise<void>(() => {})\n}\n"]}
package/dist/config.js CHANGED
@@ -1,17 +1,10 @@
1
+ import { envFlag } from './envFlag.js';
1
2
  export const packageName = 'sxy-test-runner';
2
3
  export const cliName = 'sxyt';
3
4
  export const configFileNames = ['sxyt.config', 'sxy-test-runner.config'];
4
5
  export const configLocations = ['', 'config']; // locations where the configs may be placed in proj folder
6
+ // used in output.ts
5
7
  export const debugging = false;
6
- // Parse a boolean-ish env var. Accepts true/false and 1/0, case-insensitive,
7
- // tolerant of surrounding quotes and whitespace (e.g. TIME_PROFILING="true").
8
- // Anything unrecognised (or unset) is treated as false.
9
- function envFlag(value) {
10
- if (value === undefined)
11
- return false;
12
- const normalized = value.trim().replace(/^["']|["']$/g, '').toLowerCase();
13
- return normalized === 'true' || normalized === '1';
14
- }
15
8
  // Toggle per-phase timing output with the SXYT_TIME_PROFILING env var
16
9
  // (SXYT_TIME_PROFILING=true | 1). Defaults to off so normal runs stay clean.
17
10
  export const showTimeProfiling = envFlag(process.env.SXYT_TIME_PROFILING);
@@ -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,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"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,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,oBAAoB;AACpB,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAA;AAE9B,sEAAsE;AACtE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA","sourcesContent":["import { envFlag } from './envFlag.js'\n\nexport 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\n// used in output.ts\nexport const debugging = false\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/describe.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import chalk from './packages/chalk.js';
2
+ import { checkMeta } from './checkMeta.js';
2
3
  import { debug } from './output.js';
3
4
  export function describe(theThing, testsOrMeta, possiblyTests) {
4
5
  if (!global.__sxy_test_runner__) {
@@ -15,6 +16,7 @@ export function describe(theThing, testsOrMeta, possiblyTests) {
15
16
  tests = testsOrMeta;
16
17
  }
17
18
  else {
19
+ checkMeta(`describe('${theThing}')`, testsOrMeta, ['parallelTests', 'sequentialTests']);
18
20
  meta = testsOrMeta;
19
21
  tests = possiblyTests; // eslint-disable-line no-type-assertion/no-type-assertion
20
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"describe.js","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,qBAAqB,CAAA;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAOnC,MAAM,UAAU,QAAQ,CACpB,QAAgB,EAAE,WAA4C,EAAE,aAAgC;IAEhG,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACX,oFAAoF;cAClF,0DAA0D;cAC1D,+CAA+C,CACpD,CAAA;QACD,gFAAgF;IACpF,CAAC;IAED,MAAM,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAC,eAAe,CAAA;IACtE,MAAM,CAAC,mBAAmB,CAAC,eAAe,EAAE,CAAA;IAE5C,IAAI,IAAI,GAAG,SAAS,CAAA;IACpB,IAAI,KAAK,CAAA;IACT,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QACpC,KAAK,GAAG,WAAW,CAAA;IACvB,CAAC;SAAM,CAAC;QACJ,IAAI,GAAG,WAAW,CAAA;QAClB,KAAK,GAAG,aAAiC,CAAA,CAAC,0DAA0D;IACxG,CAAC;IACD,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC;QACtC,OAAO,EAAE,mBAAmB;QAC5B,KAAK,EAAE,QAAQ;QACf,IAAI;QACJ,KAAK;KACR,CAAC,CAAA;IAEF,KAAK,CACD,KAAK,CAAC,SAAS,CAAA,GAAG,mBAAmB,GAAG;UAClC,KAAK,CAAC,SAAS,CAAA,aAAa,GAAG,KAAK,CAAC,UAAU,CAAA,GAAG,QAAQ,IAAI,CACvE,CAAA;AACL,CAAC","sourcesContent":["import chalk from './packages/chalk.js'\n\nimport { debug } from './output.js'\nimport type { DescribeCallback } from './types.js'\n\nexport type DescribeMeta = { parallelTests: boolean } | { sequentialTests: boolean }\n\nexport function describe(theThing: string, tests: DescribeCallback): void;\nexport function describe(theThing: string, meta: DescribeMeta, tests: DescribeCallback): void;\nexport function describe(\n theThing: string, testsOrMeta: DescribeCallback | DescribeMeta, possiblyTests?: DescribeCallback\n): void {\n if (!global.__sxy_test_runner__) {\n throw new Error(\n 'sxy-test-runner describe() was called, but the test framework has not initialized.'\n + ' This might be because you have run a test file directly'\n + ', instead of running \\'pnpm sxy-test-runner\\''\n )\n // todo - maybe we can initialise the framework and just run only this test file\n }\n\n const thisDescribeCounter = global.__sxy_test_runner__.describeCounter\n global.__sxy_test_runner__.describeCounter++\n\n let meta = undefined\n let tests\n if (typeof testsOrMeta === 'function') {\n tests = testsOrMeta\n } else {\n meta = testsOrMeta\n tests = possiblyTests as DescribeCallback // eslint-disable-line no-type-assertion/no-type-assertion\n }\n global.__sxy_test_runner__.describes.push({\n counter: thisDescribeCounter,\n thing: theThing,\n meta,\n tests\n })\n\n debug(\n chalk.lightgrey`${thisDescribeCounter})`\n + chalk.lightgrey` Done with ` + chalk.brightblue`${theThing}\\n`\n )\n}\n"]}
1
+ {"version":3,"file":"describe.js","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,qBAAqB,CAAA;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAOnC,MAAM,UAAU,QAAQ,CACpB,QAAgB,EAAE,WAA4C,EAAE,aAAgC;IAEhG,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACX,oFAAoF;cAClF,0DAA0D;cAC1D,+CAA+C,CACpD,CAAA;QACD,gFAAgF;IACpF,CAAC;IAED,MAAM,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAC,eAAe,CAAA;IACtE,MAAM,CAAC,mBAAmB,CAAC,eAAe,EAAE,CAAA;IAE5C,IAAI,IAAI,GAAG,SAAS,CAAA;IACpB,IAAI,KAAK,CAAA;IACT,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QACpC,KAAK,GAAG,WAAW,CAAA;IACvB,CAAC;SAAM,CAAC;QACJ,SAAS,CAAC,aAAa,QAAQ,IAAI,EAAE,WAAW,EAAE,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC,CAAA;QACvF,IAAI,GAAG,WAAW,CAAA;QAClB,KAAK,GAAG,aAAiC,CAAA,CAAC,0DAA0D;IACxG,CAAC;IACD,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC;QACtC,OAAO,EAAE,mBAAmB;QAC5B,KAAK,EAAE,QAAQ;QACf,IAAI;QACJ,KAAK;KACR,CAAC,CAAA;IAEF,KAAK,CACD,KAAK,CAAC,SAAS,CAAA,GAAG,mBAAmB,GAAG;UAClC,KAAK,CAAC,SAAS,CAAA,aAAa,GAAG,KAAK,CAAC,UAAU,CAAA,GAAG,QAAQ,IAAI,CACvE,CAAA;AACL,CAAC","sourcesContent":["import chalk from './packages/chalk.js'\n\nimport { checkMeta } from './checkMeta.js'\nimport { debug } from './output.js'\nimport type { DescribeCallback } from './types.js'\n\nexport type DescribeMeta = { parallelTests: boolean } | { sequentialTests: boolean }\n\nexport function describe(theThing: string, tests: DescribeCallback): void;\nexport function describe(theThing: string, meta: DescribeMeta, tests: DescribeCallback): void;\nexport function describe(\n theThing: string, testsOrMeta: DescribeCallback | DescribeMeta, possiblyTests?: DescribeCallback\n): void {\n if (!global.__sxy_test_runner__) {\n throw new Error(\n 'sxy-test-runner describe() was called, but the test framework has not initialized.'\n + ' This might be because you have run a test file directly'\n + ', instead of running \\'pnpm sxy-test-runner\\''\n )\n // todo - maybe we can initialise the framework and just run only this test file\n }\n\n const thisDescribeCounter = global.__sxy_test_runner__.describeCounter\n global.__sxy_test_runner__.describeCounter++\n\n let meta = undefined\n let tests\n if (typeof testsOrMeta === 'function') {\n tests = testsOrMeta\n } else {\n checkMeta(`describe('${theThing}')`, testsOrMeta, ['parallelTests', 'sequentialTests'])\n meta = testsOrMeta\n tests = possiblyTests as DescribeCallback // eslint-disable-line no-type-assertion/no-type-assertion\n }\n global.__sxy_test_runner__.describes.push({\n counter: thisDescribeCounter,\n thing: theThing,\n meta,\n tests\n })\n\n debug(\n chalk.lightgrey`${thisDescribeCounter})`\n + chalk.lightgrey` Done with ` + chalk.brightblue`${theThing}\\n`\n )\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function envFlag(value: string | undefined): boolean;
2
+ //# sourceMappingURL=envFlag.d.ts.map
@@ -0,0 +1,14 @@
1
+ // Parse a boolean-ish env var. Accepts true/false and 1/0, case-insensitive,
2
+ // tolerant of surrounding quotes and whitespace (e.g. TIME_PROFILING="true").
3
+ // Anything unrecognised (or unset) is treated as false.
4
+ export function envFlag(value) {
5
+ if (value === undefined || value === '')
6
+ return false;
7
+ const normalized = value.trim().replace(/^["']|["']$/g, '').toLowerCase();
8
+ if (normalized === 'true' || normalized === 'on' || normalized === '1')
9
+ return true;
10
+ if (normalized === 'false' || normalized === 'off' || normalized === '0')
11
+ return false;
12
+ throw new Error(`Expected env flag value '${value}'`);
13
+ }
14
+ //# sourceMappingURL=envFlag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envFlag.js","sourceRoot":"","sources":["../src/envFlag.ts"],"names":[],"mappings":"AACA,6EAA6E;AAC7E,8EAA8E;AAC9E,wDAAwD;AACxD,MAAM,UAAU,OAAO,CAAC,KAAyB;IAC7C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,KAAK,CAAA;IACrD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;IACzE,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IACnF,IAAI,UAAU,KAAK,OAAO,IAAI,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,GAAG;QAAE,OAAO,KAAK,CAAA;IACtF,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,GAAG,CAAC,CAAA;AACzD,CAAC","sourcesContent":["\r\n// Parse a boolean-ish env var. Accepts true/false and 1/0, case-insensitive,\r\n// tolerant of surrounding quotes and whitespace (e.g. TIME_PROFILING=\"true\").\r\n// Anything unrecognised (or unset) is treated as false.\r\nexport function envFlag(value: string | undefined): boolean {\r\n if (value === undefined || value === '') return false\r\n const normalized = value.trim().replace(/^[\"']|[\"']$/g, '').toLowerCase()\r\n if (normalized === 'true' || normalized === 'on' || normalized === '1') return true\r\n if (normalized === 'false' || normalized === 'off' || normalized === '0') return false\r\n throw new Error(`Expected env flag value '${value}'`)\r\n}\r\n"]}
package/dist/meta.js CHANGED
@@ -1,9 +1,11 @@
1
+ import { checkMeta } from './checkMeta.js';
1
2
  export function meta(theMeta) {
2
3
  if (!global.__sxy_test_runner__) {
3
4
  throw new Error('sxy-test-runner meta() was called, but the test framework has not initialized.'
4
5
  + ' This might be because you have run a test file directly'
5
6
  + ', instead of running \'pnpm sxy-test-runner\'');
6
7
  }
8
+ checkMeta('meta()', theMeta, ['parallelDescribes', 'sequentialDescribes']);
7
9
  global.__sxy_test_runner__.fileMeta = theMeta;
8
10
  }
9
11
  //# sourceMappingURL=meta.js.map
package/dist/meta.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"meta.js","sourceRoot":"","sources":["../src/meta.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,IAAI,CAAC,OAAiB;IAClC,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACX,gFAAgF;cAC9E,0DAA0D;cAC1D,+CAA+C,CACpD,CAAA;IACL,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,QAAQ,GAAG,OAAO,CAAA;AACjD,CAAC","sourcesContent":["\nexport type FileMeta\n = { parallelDescribes: boolean }\n | { sequentialDescribes: boolean }\n\nexport function meta(theMeta: FileMeta): void {\n if (!global.__sxy_test_runner__) {\n throw new Error(\n 'sxy-test-runner meta() was called, but the test framework has not initialized.'\n + ' This might be because you have run a test file directly'\n + ', instead of running \\'pnpm sxy-test-runner\\''\n )\n }\n\n global.__sxy_test_runner__.fileMeta = theMeta\n}\n"]}
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../src/meta.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAM1C,MAAM,UAAU,IAAI,CAAC,OAAiB;IAClC,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACX,gFAAgF;cAC9E,0DAA0D;cAC1D,+CAA+C,CACpD,CAAA;IACL,CAAC;IAED,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAAC,CAAA;IAE1E,MAAM,CAAC,mBAAmB,CAAC,QAAQ,GAAG,OAAO,CAAA;AACjD,CAAC","sourcesContent":["\nimport { checkMeta } from './checkMeta.js'\n\nexport type FileMeta\n = { parallelDescribes: boolean }\n | { sequentialDescribes: boolean }\n\nexport function meta(theMeta: FileMeta): void {\n if (!global.__sxy_test_runner__) {\n throw new Error(\n 'sxy-test-runner meta() was called, but the test framework has not initialized.'\n + ' This might be because you have run a test file directly'\n + ', instead of running \\'pnpm sxy-test-runner\\''\n )\n }\n\n checkMeta('meta()', theMeta, ['parallelDescribes', 'sequentialDescribes'])\n\n global.__sxy_test_runner__.fileMeta = theMeta\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sxy-test-runner",
3
- "version": "2.4.8",
3
+ "version": "2.4.11",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/RobertSandiford/sxy-test-runner",
6
6
  "repository": {