@rstest/core 0.2.1 → 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/{359.js → 12.js} +156 -94
- package/dist/{72.js → 171.js} +2 -1
- package/dist/223.js +135 -0
- package/dist/{920.js → 33.js} +125 -81
- package/dist/{44.js → 350.js} +6 -5
- package/dist/{813.js → 607.js} +16 -15
- package/dist/{208.js → 655.js} +60 -59
- package/dist/{355.js → 704.js} +17 -16
- package/dist/{965.js → 711.js} +6 -5
- package/dist/{443.js → 755.js} +2 -1
- package/dist/{723.js → 829.js} +5 -4
- package/dist/{867.js → 85.js} +140 -67
- package/dist/{668.js → 928.js} +3 -2
- package/dist/{25.js → 967.js} +19 -14
- package/dist/{64.js → 969.js} +2 -1
- package/dist/{285.js → 971.js} +66 -33
- package/dist/{854.js → 985.js} +153 -81
- package/dist/index.js +93 -121
- package/dist/worker.js +45 -38
- package/dist-types/index.d.ts +55 -3
- package/dist-types/worker.d.ts +124 -4
- package/globals.d.ts +2 -0
- package/package.json +6 -6
- /package/dist/{208.js.LICENSE.txt → 655.js.LICENSE.txt} +0 -0
- /package/dist/{668.js.LICENSE.txt → 928.js.LICENSE.txt} +0 -0
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
|
|
|
@@ -646,12 +651,14 @@ declare class GithubActionsReporter {
|
|
|
646
651
|
onWritePath: (path: string) => string;
|
|
647
652
|
};
|
|
648
653
|
});
|
|
654
|
+
private log;
|
|
649
655
|
onTestRunEnd({ results, testResults, getSourcemap, }: {
|
|
650
656
|
results: TestFileResult[];
|
|
651
657
|
testResults: TestResult[];
|
|
652
658
|
duration: Duration;
|
|
653
659
|
snapshotSummary: SnapshotSummary;
|
|
654
660
|
getSourcemap: GetSourcemap;
|
|
661
|
+
filterRerunTestPaths?: string[];
|
|
655
662
|
}): Promise<void>;
|
|
656
663
|
}
|
|
657
664
|
|
|
@@ -1560,7 +1567,7 @@ declare interface NewPlugin {
|
|
|
1560
1567
|
test: Test;
|
|
1561
1568
|
}
|
|
1562
1569
|
|
|
1563
|
-
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool'>> & {
|
|
1570
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects'>> & {
|
|
1564
1571
|
[key in OptionalKeys]?: RstestConfig[key];
|
|
1565
1572
|
} & {
|
|
1566
1573
|
pool: RstestPoolOptions;
|
|
@@ -1575,6 +1582,22 @@ declare interface OldPlugin {
|
|
|
1575
1582
|
test: Test;
|
|
1576
1583
|
}
|
|
1577
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
|
+
|
|
1578
1601
|
declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog';
|
|
1579
1602
|
|
|
1580
1603
|
declare type OptionsReceived = PrettyFormatOptions;
|
|
@@ -1627,6 +1650,14 @@ declare type Procedure = (...args: any[]) => any;
|
|
|
1627
1650
|
|
|
1628
1651
|
declare type Procedure_2 = (...args: any[]) => any;
|
|
1629
1652
|
|
|
1653
|
+
declare type ProjectContext = {
|
|
1654
|
+
name: string;
|
|
1655
|
+
environmentName: string;
|
|
1656
|
+
rootPath: string;
|
|
1657
|
+
configFilePath?: string;
|
|
1658
|
+
normalizedConfig: NormalizedConfig;
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1630
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] };
|
|
1631
1662
|
|
|
1632
1663
|
declare type Promisify_2<O> = {
|
|
@@ -1674,6 +1705,7 @@ export declare interface Reporter {
|
|
|
1674
1705
|
duration: Duration;
|
|
1675
1706
|
getSourcemap: GetSourcemap;
|
|
1676
1707
|
snapshotSummary: SnapshotSummary;
|
|
1708
|
+
filterRerunTestPaths?: string[];
|
|
1677
1709
|
}) => MaybePromise<void>;
|
|
1678
1710
|
/**
|
|
1679
1711
|
* Called when console log is calling.
|
|
@@ -1721,6 +1753,10 @@ export declare interface RstestConfig {
|
|
|
1721
1753
|
* @default process.cwd()
|
|
1722
1754
|
*/
|
|
1723
1755
|
root?: string;
|
|
1756
|
+
/**
|
|
1757
|
+
* Run tests from one or more projects.
|
|
1758
|
+
*/
|
|
1759
|
+
projects?: TestProject[];
|
|
1724
1760
|
/**
|
|
1725
1761
|
* Project name
|
|
1726
1762
|
*
|
|
@@ -1886,6 +1922,10 @@ declare type RstestContext = {
|
|
|
1886
1922
|
fileFilters?: string[];
|
|
1887
1923
|
/** The config file path. */
|
|
1888
1924
|
configFilePath?: string;
|
|
1925
|
+
/**
|
|
1926
|
+
* Run tests from one or more projects.
|
|
1927
|
+
*/
|
|
1928
|
+
projects: ProjectContext[];
|
|
1889
1929
|
/**
|
|
1890
1930
|
* The command type.
|
|
1891
1931
|
*
|
|
@@ -2046,6 +2086,8 @@ declare type RunnerAPI = {
|
|
|
2046
2086
|
afterAll: (fn: AfterAllListener, timeout?: number) => MaybePromise<void>;
|
|
2047
2087
|
beforeEach: (fn: BeforeEachListener, timeout?: number) => MaybePromise<void>;
|
|
2048
2088
|
afterEach: (fn: AfterEachListener, timeout?: number) => MaybePromise<void>;
|
|
2089
|
+
onTestFinished: (fn: OnTestFinishedHandler, timeout?: number) => void;
|
|
2090
|
+
onTestFailed: (fn: OnTestFailedHandler, timeout?: number) => void;
|
|
2049
2091
|
};
|
|
2050
2092
|
|
|
2051
2093
|
declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout'>;
|
|
@@ -2275,6 +2317,8 @@ declare type TestCallbackFn<ExtraContext = object> = (context: TestContext & Ext
|
|
|
2275
2317
|
|
|
2276
2318
|
declare type TestContext = {
|
|
2277
2319
|
expect: RstestExpect;
|
|
2320
|
+
onTestFinished: RunnerAPI['onTestFinished'];
|
|
2321
|
+
onTestFailed: RunnerAPI['onTestFailed'];
|
|
2278
2322
|
};
|
|
2279
2323
|
|
|
2280
2324
|
declare interface TestEachFn {
|
|
@@ -2304,6 +2348,13 @@ declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (des
|
|
|
2304
2348
|
/** The test file original path */
|
|
2305
2349
|
declare type TestPath = string;
|
|
2306
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
|
+
|
|
2307
2358
|
export declare type TestResult = {
|
|
2308
2359
|
status: TestResultStatus;
|
|
2309
2360
|
name: string;
|
|
@@ -2312,6 +2363,7 @@ export declare type TestResult = {
|
|
|
2312
2363
|
duration?: number;
|
|
2313
2364
|
errors?: FormattedError[];
|
|
2314
2365
|
retryCount?: number;
|
|
2366
|
+
project: string;
|
|
2315
2367
|
};
|
|
2316
2368
|
|
|
2317
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;
|
|
@@ -543,12 +576,14 @@ declare class GithubActionsReporter {
|
|
|
543
576
|
onWritePath: (path: string) => string;
|
|
544
577
|
};
|
|
545
578
|
});
|
|
579
|
+
private log;
|
|
546
580
|
onTestRunEnd({ results, testResults, getSourcemap, }: {
|
|
547
581
|
results: TestFileResult[];
|
|
548
582
|
testResults: TestResult[];
|
|
549
583
|
duration: Duration;
|
|
550
584
|
snapshotSummary: SnapshotSummary;
|
|
551
585
|
getSourcemap: GetSourcemap;
|
|
586
|
+
filterRerunTestPaths?: string[];
|
|
552
587
|
}): Promise<void>;
|
|
553
588
|
}
|
|
554
589
|
|
|
@@ -1306,7 +1341,7 @@ declare interface NewPlugin {
|
|
|
1306
1341
|
test: Test;
|
|
1307
1342
|
}
|
|
1308
1343
|
|
|
1309
|
-
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool'>> & {
|
|
1344
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects'>> & {
|
|
1310
1345
|
[key in OptionalKeys]?: RstestConfig[key];
|
|
1311
1346
|
} & {
|
|
1312
1347
|
pool: RstestPoolOptions;
|
|
@@ -1328,6 +1363,18 @@ declare interface OldPlugin {
|
|
|
1328
1363
|
test: Test;
|
|
1329
1364
|
}
|
|
1330
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
|
+
|
|
1331
1378
|
declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog';
|
|
1332
1379
|
|
|
1333
1380
|
declare type OptionsReceived = PrettyFormatOptions;
|
|
@@ -1378,6 +1425,14 @@ declare function printWithType<T>(name: string, value: T, print: (value: T) => s
|
|
|
1378
1425
|
|
|
1379
1426
|
declare type Procedure = (...args: any[]) => any;
|
|
1380
1427
|
|
|
1428
|
+
declare type ProjectContext = {
|
|
1429
|
+
name: string;
|
|
1430
|
+
environmentName: string;
|
|
1431
|
+
rootPath: string;
|
|
1432
|
+
configFilePath?: string;
|
|
1433
|
+
normalizedConfig: NormalizedConfig;
|
|
1434
|
+
};
|
|
1435
|
+
|
|
1381
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] };
|
|
1382
1437
|
|
|
1383
1438
|
declare type Promisify_2<O> = {
|
|
@@ -1425,6 +1480,7 @@ declare interface Reporter {
|
|
|
1425
1480
|
duration: Duration;
|
|
1426
1481
|
getSourcemap: GetSourcemap;
|
|
1427
1482
|
snapshotSummary: SnapshotSummary;
|
|
1483
|
+
filterRerunTestPaths?: string[];
|
|
1428
1484
|
}) => MaybePromise<void>;
|
|
1429
1485
|
/**
|
|
1430
1486
|
* Called when console log is calling.
|
|
@@ -1461,6 +1517,10 @@ declare interface RstestConfig {
|
|
|
1461
1517
|
* @default process.cwd()
|
|
1462
1518
|
*/
|
|
1463
1519
|
root?: string;
|
|
1520
|
+
/**
|
|
1521
|
+
* Run tests from one or more projects.
|
|
1522
|
+
*/
|
|
1523
|
+
projects?: TestProject[];
|
|
1464
1524
|
/**
|
|
1465
1525
|
* Project name
|
|
1466
1526
|
*
|
|
@@ -1620,6 +1680,10 @@ declare type RstestContext = {
|
|
|
1620
1680
|
fileFilters?: string[];
|
|
1621
1681
|
/** The config file path. */
|
|
1622
1682
|
configFilePath?: string;
|
|
1683
|
+
/**
|
|
1684
|
+
* Run tests from one or more projects.
|
|
1685
|
+
*/
|
|
1686
|
+
projects: ProjectContext[];
|
|
1623
1687
|
/**
|
|
1624
1688
|
* The command type.
|
|
1625
1689
|
*
|
|
@@ -1652,6 +1716,18 @@ declare const runInPool: (options: RunWorkerOptions["options"]) => Promise<{
|
|
|
1652
1716
|
} | TestFileResult>;
|
|
1653
1717
|
export default runInPool;
|
|
1654
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
|
+
|
|
1655
1731
|
declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout'>;
|
|
1656
1732
|
|
|
1657
1733
|
/** Runtime to Server */
|
|
@@ -1892,6 +1968,27 @@ declare type Test = (arg0: any) => boolean;
|
|
|
1892
1968
|
|
|
1893
1969
|
declare type Test_2 = TestSuite | TestCase;
|
|
1894
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
|
+
|
|
1895
1992
|
declare type TestCase = {
|
|
1896
1993
|
testPath: TestPath;
|
|
1897
1994
|
name: string;
|
|
@@ -1907,7 +2004,8 @@ declare type TestCase = {
|
|
|
1907
2004
|
inTestEach?: boolean;
|
|
1908
2005
|
context: TestContext;
|
|
1909
2006
|
only?: boolean;
|
|
1910
|
-
onFinished
|
|
2007
|
+
onFinished: OnTestFinishedHandler[];
|
|
2008
|
+
onFailed: OnTestFailedHandler[];
|
|
1911
2009
|
type: 'case';
|
|
1912
2010
|
parentNames?: string[];
|
|
1913
2011
|
/**
|
|
@@ -1918,12 +2016,20 @@ declare type TestCase = {
|
|
|
1918
2016
|
* Result of the task. if `expect.soft()` failed multiple times or `retry` was triggered.
|
|
1919
2017
|
*/
|
|
1920
2018
|
result?: TaskResult;
|
|
2019
|
+
project: string;
|
|
1921
2020
|
};
|
|
1922
2021
|
|
|
1923
2022
|
declare type TestContext = {
|
|
1924
2023
|
expect: RstestExpect;
|
|
2024
|
+
onTestFinished: RunnerAPI['onTestFinished'];
|
|
2025
|
+
onTestFailed: RunnerAPI['onTestFailed'];
|
|
1925
2026
|
};
|
|
1926
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
|
+
|
|
1927
2033
|
declare type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
|
|
1928
2034
|
|
|
1929
2035
|
declare interface TesterContext {
|
|
@@ -1939,9 +2045,20 @@ declare type TestFileResult = TestResult & {
|
|
|
1939
2045
|
snapshotResult?: SnapshotResult;
|
|
1940
2046
|
};
|
|
1941
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
|
+
|
|
1942
2052
|
/** The test file original path */
|
|
1943
2053
|
declare type TestPath = string;
|
|
1944
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
|
+
|
|
1945
2062
|
declare type TestResult = {
|
|
1946
2063
|
status: TestResultStatus;
|
|
1947
2064
|
name: string;
|
|
@@ -1950,6 +2067,7 @@ declare type TestResult = {
|
|
|
1950
2067
|
duration?: number;
|
|
1951
2068
|
errors?: FormattedError[];
|
|
1952
2069
|
retryCount?: number;
|
|
2070
|
+
project: string;
|
|
1953
2071
|
};
|
|
1954
2072
|
|
|
1955
2073
|
declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
|
|
@@ -1965,6 +2083,7 @@ declare type TestSuite = {
|
|
|
1965
2083
|
concurrent?: boolean;
|
|
1966
2084
|
sequential?: boolean;
|
|
1967
2085
|
testPath: TestPath;
|
|
2086
|
+
project: string;
|
|
1968
2087
|
/** nested cases and suite could in a suite */
|
|
1969
2088
|
tests: (TestSuite | TestCase)[];
|
|
1970
2089
|
type: 'suite';
|
|
@@ -2019,6 +2138,7 @@ declare type WithAsymmetricMatcher<T> = T | AsymmetricMatcher<unknown>;
|
|
|
2019
2138
|
|
|
2020
2139
|
declare type WorkerContext = {
|
|
2021
2140
|
rootPath: RstestContext['rootPath'];
|
|
2141
|
+
project: string;
|
|
2022
2142
|
runtimeConfig: RuntimeConfig;
|
|
2023
2143
|
};
|
|
2024
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.
|
|
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",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"@vitest/expect": "^3.2.4",
|
|
57
57
|
"@vitest/snapshot": "^3.2.4",
|
|
58
58
|
"@babel/code-frame": "^7.27.1",
|
|
59
|
-
"@jridgewell/trace-mapping": "0.3.
|
|
60
|
-
"@microsoft/api-extractor": "^7.52.
|
|
61
|
-
"@rslib/core": "0.
|
|
59
|
+
"@jridgewell/trace-mapping": "0.3.30",
|
|
60
|
+
"@microsoft/api-extractor": "^7.52.11",
|
|
61
|
+
"@rslib/core": "0.12.2",
|
|
62
62
|
"@sinonjs/fake-timers": "^14.0.0",
|
|
63
63
|
"@types/babel__code-frame": "^7.0.6",
|
|
64
64
|
"@types/jsdom": "^21.1.7",
|
|
File without changes
|
|
File without changes
|