@rstest/core 0.2.2 → 0.3.0
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/{698.js → 12.js} +87 -33
- package/dist/223.js +135 -0
- package/dist/33.js +99 -58
- package/dist/85.js +84 -12
- package/dist/967.js +12 -8
- package/dist/971.js +57 -25
- package/dist/985.js +141 -70
- package/dist/index.js +33 -61
- package/dist/worker.js +9 -4
- package/dist-types/index.d.ts +54 -3
- package/dist-types/worker.d.ts +123 -4
- package/globals.d.ts +2 -0
- package/package.json +4 -4
package/dist/worker.js
CHANGED
|
@@ -5002,7 +5002,9 @@ var __webpack_modules__ = {
|
|
|
5002
5002
|
stack: error.stack
|
|
5003
5003
|
};
|
|
5004
5004
|
if (error instanceof TestRegisterError && test?.type === 'case') errObj.message = `Can't nest describe or test inside a test. ${error.message} because it is nested within test '${test.name}'`;
|
|
5005
|
-
if (error.showDiff || void 0 === error.showDiff && void 0 !== error.expected && void 0 !== error.actual) errObj.diff = diff(err.expected, err.actual
|
|
5005
|
+
if (error.showDiff || void 0 === error.showDiff && void 0 !== error.expected && void 0 !== error.actual) errObj.diff = diff(err.expected, err.actual, {
|
|
5006
|
+
expand: false
|
|
5007
|
+
});
|
|
5006
5008
|
for (const key of [
|
|
5007
5009
|
'actual',
|
|
5008
5010
|
'expected'
|
|
@@ -5127,7 +5129,7 @@ var __webpack_modules__ = {
|
|
|
5127
5129
|
},
|
|
5128
5130
|
"./src/utils/logger.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5129
5131
|
__webpack_require__.d(__webpack_exports__, {
|
|
5130
|
-
|
|
5132
|
+
vF: ()=>src_logger
|
|
5131
5133
|
});
|
|
5132
5134
|
var external_node_os_ = __webpack_require__("node:os");
|
|
5133
5135
|
var external_node_tty_ = __webpack_require__("node:tty");
|
|
@@ -5641,7 +5643,7 @@ const createRequire = (filename, distPath, rstestContext, assetFiles, interopDef
|
|
|
5641
5643
|
interopDefault
|
|
5642
5644
|
});
|
|
5643
5645
|
} catch (err) {
|
|
5644
|
-
logger.
|
|
5646
|
+
logger.vF.error(`load file ${joinedPath} failed:\n`, err instanceof Error ? err.message : err);
|
|
5645
5647
|
}
|
|
5646
5648
|
const resolved = _require.resolve(id);
|
|
5647
5649
|
return _require(resolved);
|
|
@@ -5949,7 +5951,7 @@ const onExit = ()=>{
|
|
|
5949
5951
|
};
|
|
5950
5952
|
const runInPool = async (options)=>{
|
|
5951
5953
|
isTeardown = false;
|
|
5952
|
-
const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type, context: { runtimeConfig: { isolate } } } = options;
|
|
5954
|
+
const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type, context: { project, runtimeConfig: { isolate } } } = options;
|
|
5953
5955
|
const cleanups = [];
|
|
5954
5956
|
const exit = process.exit.bind(process);
|
|
5955
5957
|
process.exit = (code = process.exitCode || 0)=>{
|
|
@@ -5979,12 +5981,14 @@ const runInPool = async (options)=>{
|
|
|
5979
5981
|
});
|
|
5980
5982
|
const tests = await runner.collectTests();
|
|
5981
5983
|
return {
|
|
5984
|
+
project,
|
|
5982
5985
|
testPath,
|
|
5983
5986
|
tests,
|
|
5984
5987
|
errors: (0, util.o9)(unhandledErrors)
|
|
5985
5988
|
};
|
|
5986
5989
|
} catch (err) {
|
|
5987
5990
|
return {
|
|
5991
|
+
project,
|
|
5988
5992
|
testPath,
|
|
5989
5993
|
tests: [],
|
|
5990
5994
|
errors: (0, util.o9)(err)
|
|
@@ -6022,6 +6026,7 @@ const runInPool = async (options)=>{
|
|
|
6022
6026
|
return results;
|
|
6023
6027
|
} catch (err) {
|
|
6024
6028
|
return {
|
|
6029
|
+
project,
|
|
6025
6030
|
testPath,
|
|
6026
6031
|
status: 'fail',
|
|
6027
6032
|
name: '',
|
package/dist-types/index.d.ts
CHANGED
|
@@ -16,7 +16,11 @@ declare type AfterAllListener = (ctx: SuiteContext) => MaybePromise<void>;
|
|
|
16
16
|
|
|
17
17
|
export declare const afterEach: Rstest['afterEach'];
|
|
18
18
|
|
|
19
|
-
declare type AfterEachListener = (
|
|
19
|
+
declare type AfterEachListener = (params: {
|
|
20
|
+
task: {
|
|
21
|
+
result: Readonly<TestResult>;
|
|
22
|
+
};
|
|
23
|
+
}) => MaybePromise<void>;
|
|
20
24
|
|
|
21
25
|
export declare const assert: Rstest['assert'];
|
|
22
26
|
|
|
@@ -386,12 +390,13 @@ declare class DefaultReporter implements Reporter {
|
|
|
386
390
|
onTestCaseResult(_result: TestResult): void;
|
|
387
391
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
388
392
|
onExit(): Promise<void>;
|
|
389
|
-
onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, }: {
|
|
393
|
+
onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, }: {
|
|
390
394
|
results: TestFileResult[];
|
|
391
395
|
testResults: TestResult[];
|
|
392
396
|
duration: Duration;
|
|
393
397
|
snapshotSummary: SnapshotSummary;
|
|
394
398
|
getSourcemap: GetSourcemap;
|
|
399
|
+
filterRerunTestPaths?: string[];
|
|
395
400
|
}): Promise<void>;
|
|
396
401
|
}
|
|
397
402
|
|
|
@@ -653,6 +658,7 @@ declare class GithubActionsReporter {
|
|
|
653
658
|
duration: Duration;
|
|
654
659
|
snapshotSummary: SnapshotSummary;
|
|
655
660
|
getSourcemap: GetSourcemap;
|
|
661
|
+
filterRerunTestPaths?: string[];
|
|
656
662
|
}): Promise<void>;
|
|
657
663
|
}
|
|
658
664
|
|
|
@@ -1561,7 +1567,7 @@ declare interface NewPlugin {
|
|
|
1561
1567
|
test: Test;
|
|
1562
1568
|
}
|
|
1563
1569
|
|
|
1564
|
-
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool'>> & {
|
|
1570
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects'>> & {
|
|
1565
1571
|
[key in OptionalKeys]?: RstestConfig[key];
|
|
1566
1572
|
} & {
|
|
1567
1573
|
pool: RstestPoolOptions;
|
|
@@ -1576,6 +1582,22 @@ declare interface OldPlugin {
|
|
|
1576
1582
|
test: Test;
|
|
1577
1583
|
}
|
|
1578
1584
|
|
|
1585
|
+
export declare const onTestFailed: Rstest['onTestFailed'];
|
|
1586
|
+
|
|
1587
|
+
declare type OnTestFailedHandler = (params: {
|
|
1588
|
+
task: {
|
|
1589
|
+
result: Readonly<TestResult>;
|
|
1590
|
+
};
|
|
1591
|
+
}) => MaybePromise<void>;
|
|
1592
|
+
|
|
1593
|
+
export declare const onTestFinished: Rstest['onTestFinished'];
|
|
1594
|
+
|
|
1595
|
+
declare type OnTestFinishedHandler = (params: {
|
|
1596
|
+
task: {
|
|
1597
|
+
result: Readonly<TestResult>;
|
|
1598
|
+
};
|
|
1599
|
+
}) => MaybePromise<void>;
|
|
1600
|
+
|
|
1579
1601
|
declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog';
|
|
1580
1602
|
|
|
1581
1603
|
declare type OptionsReceived = PrettyFormatOptions;
|
|
@@ -1628,6 +1650,14 @@ declare type Procedure = (...args: any[]) => any;
|
|
|
1628
1650
|
|
|
1629
1651
|
declare type Procedure_2 = (...args: any[]) => any;
|
|
1630
1652
|
|
|
1653
|
+
declare type ProjectContext = {
|
|
1654
|
+
name: string;
|
|
1655
|
+
environmentName: string;
|
|
1656
|
+
rootPath: string;
|
|
1657
|
+
configFilePath?: string;
|
|
1658
|
+
normalizedConfig: NormalizedConfig;
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1631
1661
|
declare type Promisify<O> = { [K in keyof O] : O[K] extends (...args: infer A) => infer R ? Promisify<O[K]> & ((...args: A) => Promise<R>) : O[K] };
|
|
1632
1662
|
|
|
1633
1663
|
declare type Promisify_2<O> = {
|
|
@@ -1675,6 +1705,7 @@ export declare interface Reporter {
|
|
|
1675
1705
|
duration: Duration;
|
|
1676
1706
|
getSourcemap: GetSourcemap;
|
|
1677
1707
|
snapshotSummary: SnapshotSummary;
|
|
1708
|
+
filterRerunTestPaths?: string[];
|
|
1678
1709
|
}) => MaybePromise<void>;
|
|
1679
1710
|
/**
|
|
1680
1711
|
* Called when console log is calling.
|
|
@@ -1722,6 +1753,10 @@ export declare interface RstestConfig {
|
|
|
1722
1753
|
* @default process.cwd()
|
|
1723
1754
|
*/
|
|
1724
1755
|
root?: string;
|
|
1756
|
+
/**
|
|
1757
|
+
* Run tests from one or more projects.
|
|
1758
|
+
*/
|
|
1759
|
+
projects?: TestProject[];
|
|
1725
1760
|
/**
|
|
1726
1761
|
* Project name
|
|
1727
1762
|
*
|
|
@@ -1887,6 +1922,10 @@ declare type RstestContext = {
|
|
|
1887
1922
|
fileFilters?: string[];
|
|
1888
1923
|
/** The config file path. */
|
|
1889
1924
|
configFilePath?: string;
|
|
1925
|
+
/**
|
|
1926
|
+
* Run tests from one or more projects.
|
|
1927
|
+
*/
|
|
1928
|
+
projects: ProjectContext[];
|
|
1890
1929
|
/**
|
|
1891
1930
|
* The command type.
|
|
1892
1931
|
*
|
|
@@ -2047,6 +2086,8 @@ declare type RunnerAPI = {
|
|
|
2047
2086
|
afterAll: (fn: AfterAllListener, timeout?: number) => MaybePromise<void>;
|
|
2048
2087
|
beforeEach: (fn: BeforeEachListener, timeout?: number) => MaybePromise<void>;
|
|
2049
2088
|
afterEach: (fn: AfterEachListener, timeout?: number) => MaybePromise<void>;
|
|
2089
|
+
onTestFinished: (fn: OnTestFinishedHandler, timeout?: number) => void;
|
|
2090
|
+
onTestFailed: (fn: OnTestFailedHandler, timeout?: number) => void;
|
|
2050
2091
|
};
|
|
2051
2092
|
|
|
2052
2093
|
declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout'>;
|
|
@@ -2276,6 +2317,8 @@ declare type TestCallbackFn<ExtraContext = object> = (context: TestContext & Ext
|
|
|
2276
2317
|
|
|
2277
2318
|
declare type TestContext = {
|
|
2278
2319
|
expect: RstestExpect;
|
|
2320
|
+
onTestFinished: RunnerAPI['onTestFinished'];
|
|
2321
|
+
onTestFailed: RunnerAPI['onTestFailed'];
|
|
2279
2322
|
};
|
|
2280
2323
|
|
|
2281
2324
|
declare interface TestEachFn {
|
|
@@ -2305,6 +2348,13 @@ declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (des
|
|
|
2305
2348
|
/** The test file original path */
|
|
2306
2349
|
declare type TestPath = string;
|
|
2307
2350
|
|
|
2351
|
+
/**
|
|
2352
|
+
* A list of glob patterns or files that match your test projects.
|
|
2353
|
+
*
|
|
2354
|
+
* eg. ['packages/*', 'examples/node/rstest.config.ts']
|
|
2355
|
+
*/
|
|
2356
|
+
declare type TestProject = string;
|
|
2357
|
+
|
|
2308
2358
|
export declare type TestResult = {
|
|
2309
2359
|
status: TestResultStatus;
|
|
2310
2360
|
name: string;
|
|
@@ -2313,6 +2363,7 @@ export declare type TestResult = {
|
|
|
2313
2363
|
duration?: number;
|
|
2314
2364
|
errors?: FormattedError[];
|
|
2315
2365
|
retryCount?: number;
|
|
2366
|
+
project: string;
|
|
2316
2367
|
};
|
|
2317
2368
|
|
|
2318
2369
|
declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
|
package/dist-types/worker.d.ts
CHANGED
|
@@ -11,7 +11,11 @@ declare function addSerializer(plugin: Plugin_2): void;
|
|
|
11
11
|
|
|
12
12
|
declare type AfterAllListener = (ctx: SuiteContext) => MaybePromise<void>;
|
|
13
13
|
|
|
14
|
-
declare type AfterEachListener = (
|
|
14
|
+
declare type AfterEachListener = (params: {
|
|
15
|
+
task: {
|
|
16
|
+
result: Readonly<TestResult>;
|
|
17
|
+
};
|
|
18
|
+
}) => MaybePromise<void>;
|
|
15
19
|
|
|
16
20
|
declare interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T>, Matchers<T> {
|
|
17
21
|
/**
|
|
@@ -375,12 +379,13 @@ declare class DefaultReporter implements Reporter {
|
|
|
375
379
|
onTestCaseResult(_result: TestResult): void;
|
|
376
380
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
377
381
|
onExit(): Promise<void>;
|
|
378
|
-
onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, }: {
|
|
382
|
+
onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, }: {
|
|
379
383
|
results: TestFileResult[];
|
|
380
384
|
testResults: TestResult[];
|
|
381
385
|
duration: Duration;
|
|
382
386
|
snapshotSummary: SnapshotSummary;
|
|
383
387
|
getSourcemap: GetSourcemap;
|
|
388
|
+
filterRerunTestPaths?: string[];
|
|
384
389
|
}): Promise<void>;
|
|
385
390
|
}
|
|
386
391
|
|
|
@@ -392,6 +397,27 @@ declare type DefaultReporterOptions = {
|
|
|
392
397
|
summary?: boolean;
|
|
393
398
|
};
|
|
394
399
|
|
|
400
|
+
declare type DescribeAPI = DescribeFn & {
|
|
401
|
+
each: DescribeEachFn;
|
|
402
|
+
for: DescribeForFn;
|
|
403
|
+
only: DescribeAPI;
|
|
404
|
+
skip: DescribeAPI;
|
|
405
|
+
runIf: (condition: boolean) => DescribeAPI;
|
|
406
|
+
skipIf: (condition: boolean) => DescribeAPI;
|
|
407
|
+
todo: DescribeAPI;
|
|
408
|
+
concurrent: DescribeAPI;
|
|
409
|
+
sequential: DescribeAPI;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
declare interface DescribeEachFn {
|
|
413
|
+
<T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
414
|
+
<T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>) => void;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
declare type DescribeFn = (description: string, fn?: () => void) => void;
|
|
418
|
+
|
|
419
|
+
declare type DescribeForFn = <T>(cases: readonly T[]) => (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
420
|
+
|
|
395
421
|
/**
|
|
396
422
|
* @param a Expected value
|
|
397
423
|
* @param b Received value
|
|
@@ -452,6 +478,7 @@ declare type EncodedSourceMapXInput = EncodedSourceMap & XInput;
|
|
|
452
478
|
|
|
453
479
|
declare type EntryInfo = {
|
|
454
480
|
distPath: DistPath;
|
|
481
|
+
chunks: (string | number)[];
|
|
455
482
|
testPath: TestPath;
|
|
456
483
|
files?: string[];
|
|
457
484
|
};
|
|
@@ -493,6 +520,8 @@ declare interface ExpectStatic_2 extends Chai.ExpectStatic, Matchers, Asymmetric
|
|
|
493
520
|
not: AsymmetricMatchersContaining;
|
|
494
521
|
}
|
|
495
522
|
|
|
523
|
+
declare type Fixture<T, K extends keyof T, ExtraContext = object> = ((...args: any) => any) extends T[K] ? T[K] extends any ? FixtureFn<T, K, Omit<ExtraContext, Exclude<keyof T, K>>> : never : T[K] | (T[K] extends any ? FixtureFn<T, K, Omit<ExtraContext, Exclude<keyof T, K>>> : never);
|
|
524
|
+
|
|
496
525
|
declare type FixtureFn<T, K extends keyof T, ExtraContext> = (context: Omit<T, K> & ExtraContext, use: Use<T[K]>) => Promise<void>;
|
|
497
526
|
|
|
498
527
|
declare interface FixtureOptions {
|
|
@@ -502,6 +531,10 @@ declare interface FixtureOptions {
|
|
|
502
531
|
auto?: boolean;
|
|
503
532
|
}
|
|
504
533
|
|
|
534
|
+
declare type Fixtures<T extends Record<string, any> = object, ExtraContext = object> = {
|
|
535
|
+
[K in keyof T]: Fixture<T, K, ExtraContext & TestContext> | [Fixture<T, K, ExtraContext & TestContext>, FixtureOptions?];
|
|
536
|
+
};
|
|
537
|
+
|
|
505
538
|
declare type FormattedError = {
|
|
506
539
|
fullStack?: boolean;
|
|
507
540
|
message: string;
|
|
@@ -550,6 +583,7 @@ declare class GithubActionsReporter {
|
|
|
550
583
|
duration: Duration;
|
|
551
584
|
snapshotSummary: SnapshotSummary;
|
|
552
585
|
getSourcemap: GetSourcemap;
|
|
586
|
+
filterRerunTestPaths?: string[];
|
|
553
587
|
}): Promise<void>;
|
|
554
588
|
}
|
|
555
589
|
|
|
@@ -1307,7 +1341,7 @@ declare interface NewPlugin {
|
|
|
1307
1341
|
test: Test;
|
|
1308
1342
|
}
|
|
1309
1343
|
|
|
1310
|
-
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool'>> & {
|
|
1344
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects'>> & {
|
|
1311
1345
|
[key in OptionalKeys]?: RstestConfig[key];
|
|
1312
1346
|
} & {
|
|
1313
1347
|
pool: RstestPoolOptions;
|
|
@@ -1329,6 +1363,18 @@ declare interface OldPlugin {
|
|
|
1329
1363
|
test: Test;
|
|
1330
1364
|
}
|
|
1331
1365
|
|
|
1366
|
+
declare type OnTestFailedHandler = (params: {
|
|
1367
|
+
task: {
|
|
1368
|
+
result: Readonly<TestResult>;
|
|
1369
|
+
};
|
|
1370
|
+
}) => MaybePromise<void>;
|
|
1371
|
+
|
|
1372
|
+
declare type OnTestFinishedHandler = (params: {
|
|
1373
|
+
task: {
|
|
1374
|
+
result: Readonly<TestResult>;
|
|
1375
|
+
};
|
|
1376
|
+
}) => MaybePromise<void>;
|
|
1377
|
+
|
|
1332
1378
|
declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog';
|
|
1333
1379
|
|
|
1334
1380
|
declare type OptionsReceived = PrettyFormatOptions;
|
|
@@ -1379,6 +1425,14 @@ declare function printWithType<T>(name: string, value: T, print: (value: T) => s
|
|
|
1379
1425
|
|
|
1380
1426
|
declare type Procedure = (...args: any[]) => any;
|
|
1381
1427
|
|
|
1428
|
+
declare type ProjectContext = {
|
|
1429
|
+
name: string;
|
|
1430
|
+
environmentName: string;
|
|
1431
|
+
rootPath: string;
|
|
1432
|
+
configFilePath?: string;
|
|
1433
|
+
normalizedConfig: NormalizedConfig;
|
|
1434
|
+
};
|
|
1435
|
+
|
|
1382
1436
|
declare type Promisify<O> = { [K in keyof O] : O[K] extends (...args: infer A) => infer R ? Promisify<O[K]> & ((...args: A) => Promise<R>) : O[K] };
|
|
1383
1437
|
|
|
1384
1438
|
declare type Promisify_2<O> = {
|
|
@@ -1426,6 +1480,7 @@ declare interface Reporter {
|
|
|
1426
1480
|
duration: Duration;
|
|
1427
1481
|
getSourcemap: GetSourcemap;
|
|
1428
1482
|
snapshotSummary: SnapshotSummary;
|
|
1483
|
+
filterRerunTestPaths?: string[];
|
|
1429
1484
|
}) => MaybePromise<void>;
|
|
1430
1485
|
/**
|
|
1431
1486
|
* Called when console log is calling.
|
|
@@ -1462,6 +1517,10 @@ declare interface RstestConfig {
|
|
|
1462
1517
|
* @default process.cwd()
|
|
1463
1518
|
*/
|
|
1464
1519
|
root?: string;
|
|
1520
|
+
/**
|
|
1521
|
+
* Run tests from one or more projects.
|
|
1522
|
+
*/
|
|
1523
|
+
projects?: TestProject[];
|
|
1465
1524
|
/**
|
|
1466
1525
|
* Project name
|
|
1467
1526
|
*
|
|
@@ -1621,6 +1680,10 @@ declare type RstestContext = {
|
|
|
1621
1680
|
fileFilters?: string[];
|
|
1622
1681
|
/** The config file path. */
|
|
1623
1682
|
configFilePath?: string;
|
|
1683
|
+
/**
|
|
1684
|
+
* Run tests from one or more projects.
|
|
1685
|
+
*/
|
|
1686
|
+
projects: ProjectContext[];
|
|
1624
1687
|
/**
|
|
1625
1688
|
* The command type.
|
|
1626
1689
|
*
|
|
@@ -1653,6 +1716,18 @@ declare const runInPool: (options: RunWorkerOptions["options"]) => Promise<{
|
|
|
1653
1716
|
} | TestFileResult>;
|
|
1654
1717
|
export default runInPool;
|
|
1655
1718
|
|
|
1719
|
+
declare type RunnerAPI = {
|
|
1720
|
+
describe: DescribeAPI;
|
|
1721
|
+
it: TestAPIs;
|
|
1722
|
+
test: TestAPIs;
|
|
1723
|
+
beforeAll: (fn: BeforeAllListener, timeout?: number) => MaybePromise<void>;
|
|
1724
|
+
afterAll: (fn: AfterAllListener, timeout?: number) => MaybePromise<void>;
|
|
1725
|
+
beforeEach: (fn: BeforeEachListener, timeout?: number) => MaybePromise<void>;
|
|
1726
|
+
afterEach: (fn: AfterEachListener, timeout?: number) => MaybePromise<void>;
|
|
1727
|
+
onTestFinished: (fn: OnTestFinishedHandler, timeout?: number) => void;
|
|
1728
|
+
onTestFailed: (fn: OnTestFailedHandler, timeout?: number) => void;
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1656
1731
|
declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout'>;
|
|
1657
1732
|
|
|
1658
1733
|
/** Runtime to Server */
|
|
@@ -1893,6 +1968,27 @@ declare type Test = (arg0: any) => boolean;
|
|
|
1893
1968
|
|
|
1894
1969
|
declare type Test_2 = TestSuite | TestCase;
|
|
1895
1970
|
|
|
1971
|
+
declare type TestAPI<ExtraContext = object> = TestFn<ExtraContext> & {
|
|
1972
|
+
each: TestEachFn;
|
|
1973
|
+
for: TestForFn<ExtraContext>;
|
|
1974
|
+
fails: TestAPI<ExtraContext>;
|
|
1975
|
+
concurrent: TestAPI<ExtraContext>;
|
|
1976
|
+
sequential: TestAPI<ExtraContext>;
|
|
1977
|
+
only: TestAPI<ExtraContext>;
|
|
1978
|
+
skip: TestAPI<ExtraContext>;
|
|
1979
|
+
todo: TestAPI<ExtraContext>;
|
|
1980
|
+
runIf: (condition: boolean) => TestAPI<ExtraContext>;
|
|
1981
|
+
skipIf: (condition: boolean) => TestAPI<ExtraContext>;
|
|
1982
|
+
};
|
|
1983
|
+
|
|
1984
|
+
declare type TestAPIs<ExtraContext = object> = TestAPI<ExtraContext> & {
|
|
1985
|
+
extend: <T extends Record<string, any> = object>(fixtures: Fixtures<T, ExtraContext>) => TestAPIs<{
|
|
1986
|
+
[K in keyof T | keyof ExtraContext]: K extends keyof T ? T[K] : K extends keyof ExtraContext ? ExtraContext[K] : never;
|
|
1987
|
+
}>;
|
|
1988
|
+
};
|
|
1989
|
+
|
|
1990
|
+
declare type TestCallbackFn<ExtraContext = object> = (context: TestContext & ExtraContext) => MaybePromise<void>;
|
|
1991
|
+
|
|
1896
1992
|
declare type TestCase = {
|
|
1897
1993
|
testPath: TestPath;
|
|
1898
1994
|
name: string;
|
|
@@ -1908,7 +2004,8 @@ declare type TestCase = {
|
|
|
1908
2004
|
inTestEach?: boolean;
|
|
1909
2005
|
context: TestContext;
|
|
1910
2006
|
only?: boolean;
|
|
1911
|
-
onFinished
|
|
2007
|
+
onFinished: OnTestFinishedHandler[];
|
|
2008
|
+
onFailed: OnTestFailedHandler[];
|
|
1912
2009
|
type: 'case';
|
|
1913
2010
|
parentNames?: string[];
|
|
1914
2011
|
/**
|
|
@@ -1919,12 +2016,20 @@ declare type TestCase = {
|
|
|
1919
2016
|
* Result of the task. if `expect.soft()` failed multiple times or `retry` was triggered.
|
|
1920
2017
|
*/
|
|
1921
2018
|
result?: TaskResult;
|
|
2019
|
+
project: string;
|
|
1922
2020
|
};
|
|
1923
2021
|
|
|
1924
2022
|
declare type TestContext = {
|
|
1925
2023
|
expect: RstestExpect;
|
|
2024
|
+
onTestFinished: RunnerAPI['onTestFinished'];
|
|
2025
|
+
onTestFailed: RunnerAPI['onTestFailed'];
|
|
1926
2026
|
};
|
|
1927
2027
|
|
|
2028
|
+
declare interface TestEachFn {
|
|
2029
|
+
<T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
|
|
2030
|
+
<T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>, timeout?: number) => void;
|
|
2031
|
+
}
|
|
2032
|
+
|
|
1928
2033
|
declare type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
|
|
1929
2034
|
|
|
1930
2035
|
declare interface TesterContext {
|
|
@@ -1940,9 +2045,20 @@ declare type TestFileResult = TestResult & {
|
|
|
1940
2045
|
snapshotResult?: SnapshotResult;
|
|
1941
2046
|
};
|
|
1942
2047
|
|
|
2048
|
+
declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCallbackFn<ExtraContext>, timeout?: number) => void;
|
|
2049
|
+
|
|
2050
|
+
declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
|
|
2051
|
+
|
|
1943
2052
|
/** The test file original path */
|
|
1944
2053
|
declare type TestPath = string;
|
|
1945
2054
|
|
|
2055
|
+
/**
|
|
2056
|
+
* A list of glob patterns or files that match your test projects.
|
|
2057
|
+
*
|
|
2058
|
+
* eg. ['packages/*', 'examples/node/rstest.config.ts']
|
|
2059
|
+
*/
|
|
2060
|
+
declare type TestProject = string;
|
|
2061
|
+
|
|
1946
2062
|
declare type TestResult = {
|
|
1947
2063
|
status: TestResultStatus;
|
|
1948
2064
|
name: string;
|
|
@@ -1951,6 +2067,7 @@ declare type TestResult = {
|
|
|
1951
2067
|
duration?: number;
|
|
1952
2068
|
errors?: FormattedError[];
|
|
1953
2069
|
retryCount?: number;
|
|
2070
|
+
project: string;
|
|
1954
2071
|
};
|
|
1955
2072
|
|
|
1956
2073
|
declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
|
|
@@ -1966,6 +2083,7 @@ declare type TestSuite = {
|
|
|
1966
2083
|
concurrent?: boolean;
|
|
1967
2084
|
sequential?: boolean;
|
|
1968
2085
|
testPath: TestPath;
|
|
2086
|
+
project: string;
|
|
1969
2087
|
/** nested cases and suite could in a suite */
|
|
1970
2088
|
tests: (TestSuite | TestCase)[];
|
|
1971
2089
|
type: 'suite';
|
|
@@ -2020,6 +2138,7 @@ declare type WithAsymmetricMatcher<T> = T | AsymmetricMatcher<unknown>;
|
|
|
2020
2138
|
|
|
2021
2139
|
declare type WorkerContext = {
|
|
2022
2140
|
rootPath: RstestContext['rootPath'];
|
|
2141
|
+
project: string;
|
|
2023
2142
|
runtimeConfig: RuntimeConfig;
|
|
2024
2143
|
};
|
|
2025
2144
|
|
package/globals.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ declare global {
|
|
|
8
8
|
const afterAll: typeof import('@rstest/core')['afterAll'];
|
|
9
9
|
const beforeEach: typeof import('@rstest/core')['beforeEach'];
|
|
10
10
|
const afterEach: typeof import('@rstest/core')['afterEach'];
|
|
11
|
+
const onTestFinished: typeof import('@rstest/core')['onTestFinished'];
|
|
12
|
+
const onTestFailed: typeof import('@rstest/core')['onTestFailed'];
|
|
11
13
|
const rstest: typeof import('@rstest/core')['rstest'];
|
|
12
14
|
}
|
|
13
15
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"importMeta.d.ts"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"chai": "^5.
|
|
47
|
+
"chai": "^5.3.3",
|
|
48
48
|
"@types/chai": "^5.2.2",
|
|
49
|
-
"@rsbuild/core": "1.5.0
|
|
49
|
+
"@rsbuild/core": "1.5.0",
|
|
50
50
|
"birpc": "2.5.0",
|
|
51
51
|
"pathe": "^2.0.3",
|
|
52
52
|
"std-env": "^3.9.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@vitest/snapshot": "^3.2.4",
|
|
58
58
|
"@babel/code-frame": "^7.27.1",
|
|
59
59
|
"@jridgewell/trace-mapping": "0.3.30",
|
|
60
|
-
"@microsoft/api-extractor": "^7.52.
|
|
60
|
+
"@microsoft/api-extractor": "^7.52.11",
|
|
61
61
|
"@rslib/core": "0.12.2",
|
|
62
62
|
"@sinonjs/fake-timers": "^14.0.0",
|
|
63
63
|
"@types/babel__code-frame": "^7.0.6",
|