sxy-test-runner 2.3.18 → 2.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/lib/loadTestFile.js +1 -0
- package/dist/cli/lib/loadTestFile.js.map +1 -1
- package/dist/cli/lib/runTest.js +5 -1
- package/dist/cli/lib/runTest.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/meta.d.ts +7 -0
- package/dist/meta.js +9 -0
- package/dist/meta.js.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js.map +1 -1
- package/package.json +4 -4
|
@@ -37,6 +37,7 @@ export async function loadTestFile(config, testFile, refresh = 'refresh') {
|
|
|
37
37
|
await import(testFileFullUrl);
|
|
38
38
|
}
|
|
39
39
|
test.describes = global.__sxy_test_runner__?.describes ?? [];
|
|
40
|
+
test.meta = global.__sxy_test_runner__?.fileMeta;
|
|
40
41
|
test.error = false;
|
|
41
42
|
}
|
|
42
43
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadTestFile.js","sourceRoot":"","sources":["../../../src/cli/lib/loadTestFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,6BAA6B,CAAA,CAAC,wCAAwC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAGjD,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAElE,IAAI,OAAO,GAA6B,IAAI,CAAA;AAE5C,IAAI,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YACtB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,IAAI,CAAC,KAAK,GAAG,uBAAuB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;YACnD,CAAC;QACL,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI;QAEJ,OAAO,IAAI,CAAA;IACf,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,WAAW,CAAA;IAErB,OAAO,MAAM,WAAW,CAAA;AAC5B,CAAC","sourcesContent":["import { join } from 'path'\nimport chalk from '../../packages/chalk.js'\nimport { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport '../../packages/esmReload.js' // registers the test module reload hook\n\nimport { showTimeProfiling } from '../../config.js'\nimport { debug } from '../../output.js'\nimport { captureLogs } from './consoleCapture.js'\nimport type { FinalConfig, TestFile } from '../../types.js'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nlet loading: Promise<TestFile> | null = null\n\nlet importIteration = 1\nfunction importFresh(target: string): Promise<unknown> {\n return import(target + `?sxyt-instance=${importIteration++}`)\n}\n\nexport async function loadTestFile(\n config: FinalConfig,\n testFile: string,\n refresh: 'refresh' | 'cached' = 'refresh'\n): Promise<TestFile> {\n if (loading !== null) {\n debug(chalk.yellow`loadTestFile - another file is loading - waiting for it to finish`)\n await loading\n debug(chalk.yellow`previous file complete - will now load the file`)\n }\n\n const loadPromise = timeProfileAsync(`load test ${testFile}`, async () => {\n const projectDir = process.cwd()\n\n // eslint-disable-next-line camelcase\n global.__sxy_test_runner__ = {\n describes: [],\n describeCounter: 1\n }\n\n const testFileFullUrl = 'file://' + join(projectDir, testFile)\n\n const test: TestFile = { file: testFile }\n\n //// capture console.log output\n const logs: unknown[][] = []\n await captureLogs(logs, async () => {\n try {\n if (refresh === 'refresh') {\n await importFresh(testFileFullUrl)\n } else {\n await import(testFileFullUrl)\n }\n test.describes = global.__sxy_test_runner__?.describes ?? []\n test.error = false\n } catch (e) {\n test.error = `Error loading file\\n${String(e)}`\n }\n })\n test.logs = logs\n ////\n\n return test\n })\n\n loading = loadPromise\n\n return await loadPromise\n}\n"]}
|
|
1
|
+
{"version":3,"file":"loadTestFile.js","sourceRoot":"","sources":["../../../src/cli/lib/loadTestFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,6BAA6B,CAAA,CAAC,wCAAwC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAGjD,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAElE,IAAI,OAAO,GAA6B,IAAI,CAAA;AAE5C,IAAI,eAAe,GAAG,CAAC,CAAA;AACvB,SAAS,WAAW,CAAC,MAAc;IAC/B,OAAO,MAAM,CAAC,MAAM,GAAG,kBAAkB,eAAe,EAAE,EAAE,CAAC,CAAA;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAC9B,MAAmB,EACnB,QAAgB,EAChB,UAAgC,SAAS;IAEzC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACnB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAA,mEAAmE,CAAC,CAAA;QACtF,MAAM,OAAO,CAAA;QACb,KAAK,CAAC,KAAK,CAAC,MAAM,CAAA,iDAAiD,CAAC,CAAA;IACxE,CAAC;IAED,MAAM,WAAW,GAAG,gBAAgB,CAAC,aAAa,QAAQ,EAAE,EAAE,KAAK,IAAI,EAAE;QACrE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;QAEhC,qCAAqC;QACrC,MAAM,CAAC,mBAAmB,GAAG;YACzB,SAAS,EAAE,EAAE;YACb,eAAe,EAAE,CAAC;SACrB,CAAA;QAED,MAAM,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAE9D,MAAM,IAAI,GAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;QAEzC,+BAA+B;QAC/B,MAAM,IAAI,GAAgB,EAAE,CAAA;QAC5B,MAAM,WAAW,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;YAC/B,IAAI,CAAC;gBACD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;oBACxB,MAAM,WAAW,CAAC,eAAe,CAAC,CAAA;gBACtC,CAAC;qBAAM,CAAC;oBACJ,MAAM,MAAM,CAAC,eAAe,CAAC,CAAA;gBACjC,CAAC;gBACD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,mBAAmB,EAAE,SAAS,IAAI,EAAE,CAAA;gBAC5D,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,mBAAmB,EAAE,QAAQ,CAAA;gBAChD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;YACtB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,IAAI,CAAC,KAAK,GAAG,uBAAuB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;YACnD,CAAC;QACL,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI;QAEJ,OAAO,IAAI,CAAA;IACf,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,WAAW,CAAA;IAErB,OAAO,MAAM,WAAW,CAAA;AAC5B,CAAC","sourcesContent":["import { join } from 'path'\nimport chalk from '../../packages/chalk.js'\nimport { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport '../../packages/esmReload.js' // registers the test module reload hook\n\nimport { showTimeProfiling } from '../../config.js'\nimport { debug } from '../../output.js'\nimport { captureLogs } from './consoleCapture.js'\nimport type { FinalConfig, TestFile } from '../../types.js'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nlet loading: Promise<TestFile> | null = null\n\nlet importIteration = 1\nfunction importFresh(target: string): Promise<unknown> {\n return import(target + `?sxyt-instance=${importIteration++}`)\n}\n\nexport async function loadTestFile(\n config: FinalConfig,\n testFile: string,\n refresh: 'refresh' | 'cached' = 'refresh'\n): Promise<TestFile> {\n if (loading !== null) {\n debug(chalk.yellow`loadTestFile - another file is loading - waiting for it to finish`)\n await loading\n debug(chalk.yellow`previous file complete - will now load the file`)\n }\n\n const loadPromise = timeProfileAsync(`load test ${testFile}`, async () => {\n const projectDir = process.cwd()\n\n // eslint-disable-next-line camelcase\n global.__sxy_test_runner__ = {\n describes: [],\n describeCounter: 1\n }\n\n const testFileFullUrl = 'file://' + join(projectDir, testFile)\n\n const test: TestFile = { file: testFile }\n\n //// capture console.log output\n const logs: unknown[][] = []\n await captureLogs(logs, async () => {\n try {\n if (refresh === 'refresh') {\n await importFresh(testFileFullUrl)\n } else {\n await import(testFileFullUrl)\n }\n test.describes = global.__sxy_test_runner__?.describes ?? []\n test.meta = global.__sxy_test_runner__?.fileMeta\n test.error = false\n } catch (e) {\n test.error = `Error loading file\\n${String(e)}`\n }\n })\n test.logs = logs\n ////\n\n return test\n })\n\n loading = loadPromise\n\n return await loadPromise\n}\n"]}
|
package/dist/cli/lib/runTest.js
CHANGED
|
@@ -11,6 +11,10 @@ export function runTest(config, test, filters = {}) {
|
|
|
11
11
|
// run before test file
|
|
12
12
|
const fileExports = {};
|
|
13
13
|
await configBeforeEachFile(config, fileExports);
|
|
14
|
+
const parallelOverride = test.meta === undefined
|
|
15
|
+
? undefined
|
|
16
|
+
: 'parallelDescribes' in test.meta ? test.meta.parallelDescribes : !test.meta.sequentialDescribes;
|
|
17
|
+
const isParallel = parallelOverride ?? config.execution.describes === 'parallel';
|
|
14
18
|
const runDescribePromises = [];
|
|
15
19
|
for (const describe of test.describes ?? []) {
|
|
16
20
|
if (filters.describe !== undefined
|
|
@@ -18,7 +22,7 @@ export function runTest(config, test, filters = {}) {
|
|
|
18
22
|
continue;
|
|
19
23
|
const describePromise = runDescribe(config, describe, filters.it);
|
|
20
24
|
runDescribePromises.push(describePromise);
|
|
21
|
-
if (
|
|
25
|
+
if (!isParallel)
|
|
22
26
|
await describePromise;
|
|
23
27
|
}
|
|
24
28
|
let describeResults = await Promise.all(runDescribePromises);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runTest.js","sourceRoot":"","sources":["../../../src/cli/lib/runTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAM9C,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAElE,MAAM,UAAU,OAAO,CACnB,MAAmB,EACnB,IAAc,EACd,UAAgC,EAAE;IAElC,OAAO,gBAAgB,CAAC,YAAY,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,IAAI,EAAE;QACxD,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAEnB,uBAAuB;QACvB,MAAM,WAAW,GAAgB,EAAE,CAAA;QACnC,MAAM,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAE/C,MAAM,mBAAmB,GAAmC,EAAE,CAAA;QAE9D,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;YAC1C,IACI,OAAO,CAAC,QAAQ,KAAK,SAAS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ACjD,CAAC;AACL,CAAC","sourcesContent":["import { createTimeProfiler } from '../../packages/timeProfiler.js'\nimport { debug } from '../../output.js'\nimport { showTimeProfiling } from '../../config.js'\n\nimport { runTasks } from './runTasks.js'\nimport { addExports } from './addExports.js'\nimport { runDescribe } from './runDescribe.js'\n\nimport type {\n FinalConfig, DescribeResult, DescribeResultsSummary, TaskExports, TestExecutionFilters, TestFile, TestResult\n} from '../../types.js'\n\nconst { timeProfileAsync } = createTimeProfiler(showTimeProfiling)\n\nexport function runTest(\n config: FinalConfig,\n test: TestFile,\n filters: TestExecutionFilters = {}\n): Promise<TestResult> {\n return timeProfileAsync(`run test ${test.file}`, async () => {\n debug('test', test)\n\n // run before test file\n const fileExports: TaskExports = {}\n await configBeforeEachFile(config, fileExports)\n\n const parallelOverride = test.meta === undefined\n ? undefined\n : 'parallelDescribes' in test.meta ? test.meta.parallelDescribes : !test.meta.sequentialDescribes\n\n const isParallel = parallelOverride ?? config.execution.describes === 'parallel'\n\n const runDescribePromises: Array<Promise<DescribeResult>> = []\n\n for (const describe of test.describes ?? []) {\n if (\n filters.describe !== undefined\n && !describe.thing.toLowerCase().includes(filters.describe.toLowerCase())\n ) continue\n\n const describePromise = runDescribe(config, describe, filters.it)\n runDescribePromises.push(describePromise)\n if (!isParallel) await describePromise\n }\n\n let describeResults = await Promise.all(runDescribePromises)\n if (filters.it !== undefined) {\n describeResults = describeResults.filter(result => (\n result.itResults.length > 0 || result.error !== undefined\n ))\n }\n\n const describeResultsSummary: DescribeResultsSummary = {\n total: 0,\n passes: 0,\n invalid: 0,\n itsTotal: 0,\n itsPasses: 0\n }\n\n for (const describeResult of describeResults) {\n describeResultsSummary.total += +(describeResult.success !== null)\n describeResultsSummary.passes += +(describeResult.success ?? false)\n describeResultsSummary.invalid += +(describeResult.success === null)\n describeResultsSummary.itsTotal += describeResult.itResultsSummary.total\n describeResultsSummary.itsPasses += describeResult.itResultsSummary.passes\n }\n\n const testResults: TestResult = {\n file: test.file,\n success: (describeResultsSummary.total > 0)\n ? describeResultsSummary.total === describeResultsSummary.passes\n : null,\n describeResults,\n describeResultsSummary,\n logs: test.logs ?? []\n }\n\n // run after test\n await configAfterEachFile(config, fileExports)\n\n return testResults\n })\n}\n\nasync function configBeforeEachFile(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.beforeEachFile !== undefined) {\n const theExports = await runTasks(config.beforeEachFile, undefined)\n if (theExports) addExports(exports, theExports)\n }\n}\n\nasync function configAfterEachFile(config: FinalConfig, exports: TaskExports): Promise<void> {\n if (config.afterEachFile !== undefined) {\n await runTasks(config.afterEachFile, exports)\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA","sourcesContent":["\nexport { describe } from './describe.js'\nexport type { UserConfig as Config } from './types.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA","sourcesContent":["\nexport { describe } from './describe.js'\nexport { meta } from './meta.js'\nexport type { UserConfig as Config } from './types.js'\n"]}
|
package/dist/meta.d.ts
ADDED
package/dist/meta.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function meta(theMeta) {
|
|
2
|
+
if (!global.__sxy_test_runner__) {
|
|
3
|
+
throw new Error('sxy-test-runner meta() was called, but the test framework has not initialized.'
|
|
4
|
+
+ ' This might be because you have run a test file directly'
|
|
5
|
+
+ ', instead of running \'pnpm sxy-test-runner\'');
|
|
6
|
+
}
|
|
7
|
+
global.__sxy_test_runner__.fileMeta = theMeta;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=meta.js.map
|
package/dist/meta.js.map
ADDED
|
@@ -0,0 +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"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DescribeMeta } from './describe.js';
|
|
2
|
+
import { FileMeta } from './meta.js';
|
|
2
3
|
export type ExecutionMode = 'parallel' | 'sequential';
|
|
3
4
|
export type GlobPattern = string | string[];
|
|
4
5
|
export interface ExecutionConfig {
|
|
@@ -105,6 +106,7 @@ export interface DescribeResultsSummary {
|
|
|
105
106
|
export interface TestFile {
|
|
106
107
|
file: string;
|
|
107
108
|
describes?: Describe[];
|
|
109
|
+
meta?: FileMeta;
|
|
108
110
|
error?: string | false;
|
|
109
111
|
logs?: unknown[][];
|
|
110
112
|
}
|
|
@@ -141,6 +143,7 @@ export interface TestExecutionFilters {
|
|
|
141
143
|
export interface SxyTestRunnerGlobal {
|
|
142
144
|
describes: Describe[];
|
|
143
145
|
describeCounter: number;
|
|
146
|
+
fileMeta?: FileMeta;
|
|
144
147
|
}
|
|
145
148
|
declare global {
|
|
146
149
|
var __sxy_test_runner__: SxyTestRunnerGlobal | undefined;
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,+EAA+E","sourcesContent":["// Shared types for the test-run data model, user config, and CLI plumbing.\n// The config/result shapes are inferred from usage across the old awaitful\n// source (defaultConfig.js, validateConfig.js, init.js's template, and the\n// run*/parseDescribe/showTestResult modules) - there was no prior type source.\n\nimport { DescribeMeta } from './describe.js'\n\nexport type ExecutionMode = 'parallel' | 'sequential'\nexport type GlobPattern = string | string[]\n\nexport interface ExecutionConfig {\n files: ExecutionMode\n describes: ExecutionMode\n tests: ExecutionMode\n}\n\nexport interface WatchConfig {\n watchFilesBase: string\n watchFiles: GlobPattern\n watchFilesIgnore: GlobPattern\n runAllOnStartup: boolean\n reRunFailingTests: boolean\n ttyActionsOnKeypress: boolean\n}\n\nexport type TaskExports = Record<string, unknown>\nexport type ConfigTaskFn = (parcel?: TaskExports) => TaskExports | void | Promise<TaskExports | void>\n// a task may also be a file path (relative to the project root) to dynamically import\nexport type ConfigTask = ConfigTaskFn | string\nexport type ConfigTasks = ConfigTask | ConfigTask[]\n\nexport interface FinalConfig {\n testsBase: string\n tests: GlobPattern\n testsFilter?: string\n testsIgnore: GlobPattern\n setup?: ConfigTasks\n beforeEachFile?: ConfigTasks\n afterEachFile?: ConfigTasks\n beforeEachDescribe?: ConfigTasks\n afterEachDescribe?: ConfigTasks\n beforeEachTest?: ConfigTasks\n afterEachTest?: ConfigTasks\n teardown?: ConfigTasks\n showErrorTrace: boolean\n compact: boolean\n execution: ExecutionConfig\n watch: WatchConfig\n}\n\nexport type UserConfig = Partial<Omit<FinalConfig, 'testsFilter' | 'execution' | 'watch'>> & {\n execution?: Partial<ExecutionConfig>\n watch?: Partial<WatchConfig>\n}\n\nexport type UserConfigInternal = UserConfig & Partial<Pick<FinalConfig, 'testsFilter'>>\n\n\n// -- test-run data model --------------------------------------------------\n\nexport type TestParcel = TaskExports\n\nexport interface DescribeParcel extends TaskExports {\n it: (should: string, test: (parcel: TestParcel) => void | Promise<void>) => void\n test: (should: string, test: (parcel: TestParcel) => void | Promise<void>) => void\n afterDescribe: (func: () => void | Promise<void>) => void\n beforeEachTest: (func: () => TaskExports | void | Promise<TaskExports | void>) => void\n afterEachTest: (func: () => void | Promise<void>) => void\n}\n\nexport type DescribeCallback = (parcel: DescribeParcel) => void | Promise<void>\n\nexport interface Describe {\n counter: number\n thing: string\n meta?: DescribeMeta\n tests: DescribeCallback\n}\n\nexport interface It {\n counter: number\n should: string\n test: (parcel: TestParcel) => void | Promise<void>\n}\n\nexport interface ParsedDescribe {\n its: It[]\n beforeDescribeExports: TaskExports\n afterDescribeFunc?: () => void | Promise<void>\n beforeEachTestFunc?: () => TaskExports | void | Promise<TaskExports | void>\n afterEachTestFunc?: () => void | Promise<void>\n error?: unknown\n}\n\nexport interface TestError extends Error {\n actual?: unknown\n expected?: unknown\n}\n\nexport interface ItResult {\n counter: number\n should: string\n success: boolean | null\n time: number\n error?: TestError\n logs: unknown[][]\n}\n\nexport interface ItResultsSummary {\n total: number\n passes: number\n}\n\nexport interface DescribeResult {\n counter: number\n thing: string\n success: boolean | null\n // total elapsed for the whole describe, filled in by runDescribe once it has finished\n time: number\n itResults: ItResult[]\n itResultsSummary: ItResultsSummary\n logs?: unknown[][]\n error?: unknown\n}\n\nexport interface DescribeResultsSummary {\n total: number\n passes: number\n invalid: number\n itsTotal: number\n itsPasses: number\n}\n\nexport interface TestFile {\n file: string\n describes?: Describe[]\n error?: string | false\n logs?: unknown[][]\n}\n\nexport interface TestResult {\n file: string\n success: boolean | null\n describeResults: DescribeResult[]\n describeResultsSummary: DescribeResultsSummary\n logs: unknown[][]\n}\n\nexport interface TestsResultsSummary {\n total: number\n passes: number\n invalid: number\n describesTotal: number\n describesPasses: number\n describesInvalid: number\n itsTotal: number\n itsPasses: number\n}\n\nexport type DependencyTrees = Record<string, string[]>\n\nexport type OutFn = (...texts: unknown[]) => void\n\n\n\n// -- CLI argument parsing ---------------------------------------------------\n\nexport interface AllowedArgument {\n flag?: string\n hasValue: boolean\n}\n\nexport type AllowedArguments = Record<string, AllowedArgument>\nexport type AllowedFlags = Record<string, string>\nexport type ParsedArguments = Record<string, string | true>\n\nexport interface TestExecutionFilters {\n describe?: string\n it?: string\n}\n\n// -- globals ----------------------------------------------------------------\n\nexport interface SxyTestRunnerGlobal {\n describes: Describe[]\n describeCounter: number\n}\ndeclare global {\n // eslint-disable-next-line camelcase\n var __sxy_test_runner__: SxyTestRunnerGlobal | undefined\n // eslint-disable-next-line camelcase\n var __sxyt_commandLineArguments: string[]\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,+EAA+E","sourcesContent":["// Shared types for the test-run data model, user config, and CLI plumbing.\n// The config/result shapes are inferred from usage across the old awaitful\n// source (defaultConfig.js, validateConfig.js, init.js's template, and the\n// run*/parseDescribe/showTestResult modules) - there was no prior type source.\n\nimport { DescribeMeta } from './describe.js'\nimport { FileMeta } from './meta.js'\n\nexport type ExecutionMode = 'parallel' | 'sequential'\nexport type GlobPattern = string | string[]\n\nexport interface ExecutionConfig {\n files: ExecutionMode\n describes: ExecutionMode\n tests: ExecutionMode\n}\n\nexport interface WatchConfig {\n watchFilesBase: string\n watchFiles: GlobPattern\n watchFilesIgnore: GlobPattern\n runAllOnStartup: boolean\n reRunFailingTests: boolean\n ttyActionsOnKeypress: boolean\n}\n\nexport type TaskExports = Record<string, unknown>\nexport type ConfigTaskFn = (parcel?: TaskExports) => TaskExports | void | Promise<TaskExports | void>\n// a task may also be a file path (relative to the project root) to dynamically import\nexport type ConfigTask = ConfigTaskFn | string\nexport type ConfigTasks = ConfigTask | ConfigTask[]\n\nexport interface FinalConfig {\n testsBase: string\n tests: GlobPattern\n testsFilter?: string\n testsIgnore: GlobPattern\n setup?: ConfigTasks\n beforeEachFile?: ConfigTasks\n afterEachFile?: ConfigTasks\n beforeEachDescribe?: ConfigTasks\n afterEachDescribe?: ConfigTasks\n beforeEachTest?: ConfigTasks\n afterEachTest?: ConfigTasks\n teardown?: ConfigTasks\n showErrorTrace: boolean\n compact: boolean\n execution: ExecutionConfig\n watch: WatchConfig\n}\n\nexport type UserConfig = Partial<Omit<FinalConfig, 'testsFilter' | 'execution' | 'watch'>> & {\n execution?: Partial<ExecutionConfig>\n watch?: Partial<WatchConfig>\n}\n\nexport type UserConfigInternal = UserConfig & Partial<Pick<FinalConfig, 'testsFilter'>>\n\n\n// -- test-run data model --------------------------------------------------\n\nexport type TestParcel = TaskExports\n\nexport interface DescribeParcel extends TaskExports {\n it: (should: string, test: (parcel: TestParcel) => void | Promise<void>) => void\n test: (should: string, test: (parcel: TestParcel) => void | Promise<void>) => void\n afterDescribe: (func: () => void | Promise<void>) => void\n beforeEachTest: (func: () => TaskExports | void | Promise<TaskExports | void>) => void\n afterEachTest: (func: () => void | Promise<void>) => void\n}\n\nexport type DescribeCallback = (parcel: DescribeParcel) => void | Promise<void>\n\nexport interface Describe {\n counter: number\n thing: string\n meta?: DescribeMeta\n tests: DescribeCallback\n}\n\nexport interface It {\n counter: number\n should: string\n test: (parcel: TestParcel) => void | Promise<void>\n}\n\nexport interface ParsedDescribe {\n its: It[]\n beforeDescribeExports: TaskExports\n afterDescribeFunc?: () => void | Promise<void>\n beforeEachTestFunc?: () => TaskExports | void | Promise<TaskExports | void>\n afterEachTestFunc?: () => void | Promise<void>\n error?: unknown\n}\n\nexport interface TestError extends Error {\n actual?: unknown\n expected?: unknown\n}\n\nexport interface ItResult {\n counter: number\n should: string\n success: boolean | null\n time: number\n error?: TestError\n logs: unknown[][]\n}\n\nexport interface ItResultsSummary {\n total: number\n passes: number\n}\n\nexport interface DescribeResult {\n counter: number\n thing: string\n success: boolean | null\n // total elapsed for the whole describe, filled in by runDescribe once it has finished\n time: number\n itResults: ItResult[]\n itResultsSummary: ItResultsSummary\n logs?: unknown[][]\n error?: unknown\n}\n\nexport interface DescribeResultsSummary {\n total: number\n passes: number\n invalid: number\n itsTotal: number\n itsPasses: number\n}\n\nexport interface TestFile {\n file: string\n describes?: Describe[]\n meta?: FileMeta\n error?: string | false\n logs?: unknown[][]\n}\n\nexport interface TestResult {\n file: string\n success: boolean | null\n describeResults: DescribeResult[]\n describeResultsSummary: DescribeResultsSummary\n logs: unknown[][]\n}\n\nexport interface TestsResultsSummary {\n total: number\n passes: number\n invalid: number\n describesTotal: number\n describesPasses: number\n describesInvalid: number\n itsTotal: number\n itsPasses: number\n}\n\nexport type DependencyTrees = Record<string, string[]>\n\nexport type OutFn = (...texts: unknown[]) => void\n\n\n\n// -- CLI argument parsing ---------------------------------------------------\n\nexport interface AllowedArgument {\n flag?: string\n hasValue: boolean\n}\n\nexport type AllowedArguments = Record<string, AllowedArgument>\nexport type AllowedFlags = Record<string, string>\nexport type ParsedArguments = Record<string, string | true>\n\nexport interface TestExecutionFilters {\n describe?: string\n it?: string\n}\n\n// -- globals ----------------------------------------------------------------\n\nexport interface SxyTestRunnerGlobal {\n describes: Describe[]\n describeCounter: number\n fileMeta?: FileMeta\n}\ndeclare global {\n // eslint-disable-next-line camelcase\n var __sxy_test_runner__: SxyTestRunnerGlobal | undefined\n // eslint-disable-next-line camelcase\n var __sxyt_commandLineArguments: string[]\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sxy-test-runner",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.19",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/RobertSandiford/sxy-test-runner",
|
|
6
6
|
"repository": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"minimatch": "^5.1.9",
|
|
50
50
|
"node-watch": "^0.7.4",
|
|
51
51
|
"rimraf": "^6.1.3",
|
|
52
|
-
"sxy-lib": "^3.0.
|
|
52
|
+
"sxy-lib": "^3.0.5"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/chai-as-promised": "^7.1.8",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"@types/sinon": "^17.0.4",
|
|
61
61
|
"@types/sinon-chai": "^3.2.12",
|
|
62
62
|
"@typescript-eslint/utils": "^8.65.0",
|
|
63
|
-
"chai": "^6.
|
|
63
|
+
"chai": "^6.2.2",
|
|
64
64
|
"chai-as-promised": "^7.1.2",
|
|
65
65
|
"chai-string": "^1.6.0",
|
|
66
66
|
"eslint": "^9.39.5",
|
|
67
|
-
"eslint-config-tungsten-flat": "^0.2.
|
|
67
|
+
"eslint-config-tungsten-flat": "^0.2.5",
|
|
68
68
|
"mocha": "^9.2.2",
|
|
69
69
|
"mocha-steps": "^1.3.0",
|
|
70
70
|
"nodemon": "^2.0.22",
|