@rstest/core 0.7.3 → 0.7.5
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/0~130.js +2 -1
- package/dist/0~151.js +18 -21
- package/dist/0~173.js +49 -7
- package/dist/0~255.js +1 -1
- package/dist/0~403.js +2 -1
- package/dist/0~426.js +5 -3
- package/dist/0~583.js +3 -2
- package/dist/0~588.js +5 -3
- package/dist/0~62.js +1 -1
- package/dist/0~634.js +55 -7
- package/dist/0~809.js +1 -1
- package/dist/0~835.js +5 -3
- package/dist/{0~122.js → 0~89.js} +178 -47
- package/dist/0~919.js +1 -1
- package/dist/0~923.js +4 -3
- package/dist/0~973.js +50 -0
- package/dist/131.js +42 -22
- package/dist/{946.js → 157.js} +10 -890
- package/dist/198.js +4 -0
- package/dist/{404.js → 216.js} +1 -2
- package/dist/278.js +765 -0
- package/dist/554.js +5 -6714
- package/dist/693.js +91 -0
- package/dist/734.js +5 -3
- package/dist/881.js +4 -0
- package/dist/913.js +6718 -0
- package/dist/globalSetupWorker.d.ts +9 -0
- package/dist/globalSetupWorker.js +115 -0
- package/dist/index.d.ts +168 -21
- package/dist/index.js +1 -1
- package/dist/worker.d.ts +166 -21
- package/package.json +3 -2
- /package/dist/{554.js.LICENSE.txt → 913.js.LICENSE.txt} +0 -0
package/dist/worker.d.ts
CHANGED
|
@@ -13,11 +13,7 @@ declare function addSerializer(plugin: Plugin_2): void;
|
|
|
13
13
|
|
|
14
14
|
declare type AfterAllListener = (ctx: SuiteContext) => MaybePromise<void>;
|
|
15
15
|
|
|
16
|
-
declare type AfterEachListener = (
|
|
17
|
-
task: {
|
|
18
|
-
result: Readonly<TestResult>;
|
|
19
|
-
};
|
|
20
|
-
}) => MaybePromise<void>;
|
|
16
|
+
declare type AfterEachListener = (ctx: TestContext) => MaybePromise<void>;
|
|
21
17
|
|
|
22
18
|
declare interface Assertion<T = any> extends VitestAssertion<Chai.Assertion, T>, JestAssertion<T>, Matchers<T> {
|
|
23
19
|
/**
|
|
@@ -246,7 +242,7 @@ declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
|
|
|
246
242
|
|
|
247
243
|
declare type BeforeAllListener = (ctx: SuiteContext) => MaybePromise<void | AfterAllListener>;
|
|
248
244
|
|
|
249
|
-
declare type BeforeEachListener = () => MaybePromise<void | AfterEachListener>;
|
|
245
|
+
declare type BeforeEachListener = (ctx: TestContext) => MaybePromise<void | AfterEachListener>;
|
|
250
246
|
|
|
251
247
|
declare interface BranchMapping {
|
|
252
248
|
loc: Range_2;
|
|
@@ -319,6 +315,59 @@ declare interface Constructable {
|
|
|
319
315
|
new (...args: any[]): any;
|
|
320
316
|
}
|
|
321
317
|
|
|
318
|
+
/**
|
|
319
|
+
* Base class for writing content
|
|
320
|
+
*/
|
|
321
|
+
declare class ContentWriter {
|
|
322
|
+
/**
|
|
323
|
+
* returns the colorized version of a string. Typically,
|
|
324
|
+
* content writers that write to files will return the
|
|
325
|
+
* same string and ones writing to a tty will wrap it in
|
|
326
|
+
* appropriate escape sequences.
|
|
327
|
+
*/
|
|
328
|
+
colorize(str: string, clazz?: string): string;
|
|
329
|
+
/**
|
|
330
|
+
* writes a string appended with a newline to the destination
|
|
331
|
+
*/
|
|
332
|
+
println(str: string): void;
|
|
333
|
+
/**
|
|
334
|
+
* closes this content writer. Should be called after all writes are complete.
|
|
335
|
+
*/
|
|
336
|
+
close(): void;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
declare interface Context {
|
|
340
|
+
data: any;
|
|
341
|
+
dir: string;
|
|
342
|
+
sourceFinder(filepath: string): string;
|
|
343
|
+
watermarks: Watermarks;
|
|
344
|
+
writer: FileWriter;
|
|
345
|
+
/**
|
|
346
|
+
* returns the coverage class given a coverage
|
|
347
|
+
* types and a percentage value.
|
|
348
|
+
*/
|
|
349
|
+
classForPercent(type: keyof Watermarks, value: number): string;
|
|
350
|
+
/**
|
|
351
|
+
* returns the source code for the specified file path or throws if
|
|
352
|
+
* the source could not be found.
|
|
353
|
+
*/
|
|
354
|
+
getSource(filepath: string): string;
|
|
355
|
+
getTree(summarizer?: Summarizers): Tree;
|
|
356
|
+
/**
|
|
357
|
+
* returns a full visitor given a partial one.
|
|
358
|
+
*/
|
|
359
|
+
getVisitor<N extends Node_2 = Node_2>(visitor: Partial<Visitor<N>>): Visitor<N>;
|
|
360
|
+
/**
|
|
361
|
+
* returns a FileWriter implementation for reporting use. Also available
|
|
362
|
+
* as the `writer` property on the context.
|
|
363
|
+
*/
|
|
364
|
+
getWriter(): FileWriter;
|
|
365
|
+
/**
|
|
366
|
+
* returns an XML writer for the supplied content writer
|
|
367
|
+
*/
|
|
368
|
+
getXmlWriter(contentWriter: ContentWriter): XmlWriter;
|
|
369
|
+
}
|
|
370
|
+
|
|
322
371
|
declare class CounterMap<K> extends DefaultMap<K, number> {
|
|
323
372
|
constructor();
|
|
324
373
|
// compat for jest-image-snapshot https://github.com/vitest-dev/vitest/issues/7322
|
|
@@ -376,9 +425,19 @@ declare type CoverageOptions = {
|
|
|
376
425
|
provider?: 'istanbul';
|
|
377
426
|
/**
|
|
378
427
|
* The reporters to use for coverage collection.
|
|
428
|
+
* Supports built-in istanbul reporters and custom reporters (e.g., '@canyonjs/report-html').
|
|
379
429
|
* @default ['text', 'html', 'clover', 'json']
|
|
430
|
+
* @example
|
|
431
|
+
* // Built-in reporters
|
|
432
|
+
* reporters: ['text', 'html', ['json', { file: 'coverage.json' }]]
|
|
433
|
+
*
|
|
434
|
+
* // Custom reporters
|
|
435
|
+
* reporters: ['@canyonjs/report-html', ['custom-reporter', { outputDir: './reports' }]]
|
|
436
|
+
*
|
|
437
|
+
* // Mixed usage
|
|
438
|
+
* reporters: ['text', '@canyonjs/report-html', ['html', { subdir: 'html-report' }]]
|
|
380
439
|
*/
|
|
381
|
-
reporters?:
|
|
440
|
+
reporters?: SupportedReporter[];
|
|
382
441
|
/**
|
|
383
442
|
* The directory to store coverage reports.
|
|
384
443
|
* @default './coverage'
|
|
@@ -457,6 +516,9 @@ declare interface CustomMatcher {
|
|
|
457
516
|
toBeOneOf: <T>(sample: Array<T>) => any;
|
|
458
517
|
}
|
|
459
518
|
|
|
519
|
+
/** Custom reporter configuration for non-istanbul reporters */
|
|
520
|
+
declare type CustomReporter = string | [string, Record<string, unknown>];
|
|
521
|
+
|
|
460
522
|
declare interface DecodedSourceMap extends SourceMapV3 {
|
|
461
523
|
mappings: SourceMapSegment[][];
|
|
462
524
|
}
|
|
@@ -497,12 +559,13 @@ declare class DefaultReporter implements Reporter {
|
|
|
497
559
|
onTestCaseResult(): void;
|
|
498
560
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
499
561
|
onExit(): Promise<void>;
|
|
500
|
-
onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, }: {
|
|
562
|
+
onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, unhandledErrors, }: {
|
|
501
563
|
results: TestFileResult[];
|
|
502
564
|
testResults: TestResult[];
|
|
503
565
|
duration: Duration;
|
|
504
566
|
snapshotSummary: SnapshotSummary;
|
|
505
567
|
getSourcemap: GetSourcemap;
|
|
568
|
+
unhandledErrors?: Error[];
|
|
506
569
|
filterRerunTestPaths?: string[];
|
|
507
570
|
}): Promise<void>;
|
|
508
571
|
}
|
|
@@ -680,6 +743,29 @@ declare interface FileOptions {
|
|
|
680
743
|
file: string;
|
|
681
744
|
}
|
|
682
745
|
|
|
746
|
+
/**
|
|
747
|
+
* utility for writing files under a specific directory
|
|
748
|
+
*/
|
|
749
|
+
declare class FileWriter {
|
|
750
|
+
constructor(baseDir: string);
|
|
751
|
+
static startCapture(): void;
|
|
752
|
+
static stopCapture(): void;
|
|
753
|
+
static getOutput(): string;
|
|
754
|
+
static resetOutput(): void;
|
|
755
|
+
/**
|
|
756
|
+
* returns a FileWriter that is rooted at the supplied subdirectory
|
|
757
|
+
*/
|
|
758
|
+
writeForDir(subdir: string): FileWriter;
|
|
759
|
+
/**
|
|
760
|
+
* copies a file from a source directory to a destination name
|
|
761
|
+
*/
|
|
762
|
+
copyFile(source: string, dest: string, header?: string): void;
|
|
763
|
+
/**
|
|
764
|
+
* returns a content writer for writing content to the supplied file.
|
|
765
|
+
*/
|
|
766
|
+
writeFile(file: string | null): ContentWriter;
|
|
767
|
+
}
|
|
768
|
+
|
|
683
769
|
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);
|
|
684
770
|
|
|
685
771
|
declare type FixtureFn<T, K extends keyof T, ExtraContext> = (context: Omit<T, K> & ExtraContext, use: Use<T[K]>) => Promise<void>;
|
|
@@ -1584,10 +1670,11 @@ declare interface Node_2 {
|
|
|
1584
1670
|
visit(visitor: Visitor, state: any): void;
|
|
1585
1671
|
}
|
|
1586
1672
|
|
|
1587
|
-
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'exclude'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
1673
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
1588
1674
|
pool: RstestPoolOptions;
|
|
1589
1675
|
coverage: NormalizedCoverageOptions;
|
|
1590
1676
|
setupFiles: string[];
|
|
1677
|
+
globalSetup: string[];
|
|
1591
1678
|
exclude: {
|
|
1592
1679
|
patterns: string[];
|
|
1593
1680
|
override?: boolean;
|
|
@@ -1610,8 +1697,9 @@ declare type NormalizedFixtures = Record<string, NormalizedFixture>;
|
|
|
1610
1697
|
|
|
1611
1698
|
declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
|
|
1612
1699
|
|
|
1613
|
-
declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles'>> & Pick<NormalizedConfig, OptionalKeys> & {
|
|
1700
|
+
declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup'>> & Pick<NormalizedConfig, OptionalKeys> & {
|
|
1614
1701
|
setupFiles: string[];
|
|
1702
|
+
globalSetup: string[];
|
|
1615
1703
|
};
|
|
1616
1704
|
|
|
1617
1705
|
declare interface OldPlugin {
|
|
@@ -1619,17 +1707,9 @@ declare interface OldPlugin {
|
|
|
1619
1707
|
test: Test;
|
|
1620
1708
|
}
|
|
1621
1709
|
|
|
1622
|
-
declare type OnTestFailedHandler = (
|
|
1623
|
-
task: {
|
|
1624
|
-
result: Readonly<TestResult>;
|
|
1625
|
-
};
|
|
1626
|
-
}) => MaybePromise<void>;
|
|
1710
|
+
declare type OnTestFailedHandler = (ctx: TestContext) => MaybePromise<void>;
|
|
1627
1711
|
|
|
1628
|
-
declare type OnTestFinishedHandler = (
|
|
1629
|
-
task: {
|
|
1630
|
-
result: Readonly<TestResult>;
|
|
1631
|
-
};
|
|
1632
|
-
}) => MaybePromise<void>;
|
|
1712
|
+
declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
|
|
1633
1713
|
|
|
1634
1714
|
declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'resolveSnapshotPath';
|
|
1635
1715
|
|
|
@@ -1702,6 +1782,7 @@ declare type ProjectContext = {
|
|
|
1702
1782
|
outputModule: boolean;
|
|
1703
1783
|
configFilePath?: string;
|
|
1704
1784
|
normalizedConfig: NormalizedProjectConfig;
|
|
1785
|
+
_globalSetups: boolean;
|
|
1705
1786
|
};
|
|
1706
1787
|
|
|
1707
1788
|
declare interface ProjectOptions {
|
|
@@ -1738,6 +1819,15 @@ declare interface RawSnapshotInfo {
|
|
|
1738
1819
|
|
|
1739
1820
|
declare type Refs = Array<unknown>;
|
|
1740
1821
|
|
|
1822
|
+
declare class ReportBase {
|
|
1823
|
+
constructor(options?: Partial<ReportBaseOptions>);
|
|
1824
|
+
execute(context: Context): void;
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
declare interface ReportBaseOptions {
|
|
1828
|
+
summarizer: Summarizers;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1741
1831
|
declare interface Reporter {
|
|
1742
1832
|
/**
|
|
1743
1833
|
* Called before test file run.
|
|
@@ -1772,11 +1862,12 @@ declare interface Reporter {
|
|
|
1772
1862
|
/**
|
|
1773
1863
|
* Called after all tests have finished running.
|
|
1774
1864
|
*/
|
|
1775
|
-
onTestRunEnd?: ({ results, testResults, duration, getSourcemap, snapshotSummary, }: {
|
|
1865
|
+
onTestRunEnd?: ({ results, testResults, duration, getSourcemap, snapshotSummary, unhandledErrors, }: {
|
|
1776
1866
|
results: TestFileResult[];
|
|
1777
1867
|
testResults: TestResult[];
|
|
1778
1868
|
duration: Duration;
|
|
1779
1869
|
getSourcemap: GetSourcemap;
|
|
1870
|
+
unhandledErrors?: Error[];
|
|
1780
1871
|
snapshotSummary: SnapshotSummary;
|
|
1781
1872
|
filterRerunTestPaths?: string[];
|
|
1782
1873
|
}) => MaybePromise<void>;
|
|
@@ -1873,6 +1964,12 @@ declare interface RstestConfig {
|
|
|
1873
1964
|
* Path to setup files. They will be run before each test file.
|
|
1874
1965
|
*/
|
|
1875
1966
|
setupFiles?: string[] | string;
|
|
1967
|
+
/**
|
|
1968
|
+
* Path to global setup files, relative to project root.
|
|
1969
|
+
* A global setup file can either export named functions `setup` and `teardown`
|
|
1970
|
+
* or a `default` function that returns a teardown function.
|
|
1971
|
+
*/
|
|
1972
|
+
globalSetup?: string[] | string;
|
|
1876
1973
|
/**
|
|
1877
1974
|
* Retry the test specific number of times if it fails.
|
|
1878
1975
|
* @default 0
|
|
@@ -2336,6 +2433,11 @@ declare type SuiteContext = {
|
|
|
2336
2433
|
filepath: TestPath;
|
|
2337
2434
|
};
|
|
2338
2435
|
|
|
2436
|
+
declare type Summarizers = "flat" | "nested" | "pkg" | "defaultSummarizer";
|
|
2437
|
+
|
|
2438
|
+
/** Union type for all supported reporter types */
|
|
2439
|
+
declare type SupportedReporter = keyof ReportOptions | ReportWithOptions | ReportBase | CustomReporter;
|
|
2440
|
+
|
|
2339
2441
|
declare interface SyncExpectationResult {
|
|
2340
2442
|
pass: boolean;
|
|
2341
2443
|
message: () => string;
|
|
@@ -2431,6 +2533,15 @@ declare type TestCaseInfo = {
|
|
|
2431
2533
|
};
|
|
2432
2534
|
|
|
2433
2535
|
declare type TestContext = {
|
|
2536
|
+
/**
|
|
2537
|
+
* Metadata of the current test
|
|
2538
|
+
*/
|
|
2539
|
+
task: {
|
|
2540
|
+
/** Test name provided by user */
|
|
2541
|
+
name: string;
|
|
2542
|
+
/** Result of the current test, undefined if the test is not run yet */
|
|
2543
|
+
result?: TestResult;
|
|
2544
|
+
};
|
|
2434
2545
|
expect: RstestExpect;
|
|
2435
2546
|
onTestFinished: RunnerAPI['onTestFinished'];
|
|
2436
2547
|
onTestFailed: RunnerAPI['onTestFailed'];
|
|
@@ -2571,6 +2682,11 @@ declare class TraceMap implements SourceMap {
|
|
|
2571
2682
|
constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
|
|
2572
2683
|
}
|
|
2573
2684
|
|
|
2685
|
+
declare interface Tree<N extends Node_2 = Node_2> {
|
|
2686
|
+
getRoot(): N;
|
|
2687
|
+
visit(visitor: Partial<Visitor<N>>, state: any): void;
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2574
2690
|
declare interface UncheckedSnapshot {
|
|
2575
2691
|
filePath: string;
|
|
2576
2692
|
keys: Array<string>;
|
|
@@ -2603,6 +2719,15 @@ declare type VitestAssertion<
|
|
|
2603
2719
|
T
|
|
2604
2720
|
> = { [K in keyof A] : A[K] extends Chai.Assertion ? Assertion<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T> } & ((type: string, message?: string) => Assertion);
|
|
2605
2721
|
|
|
2722
|
+
declare type Watermark = [number, number];
|
|
2723
|
+
|
|
2724
|
+
declare interface Watermarks {
|
|
2725
|
+
statements: Watermark;
|
|
2726
|
+
functions: Watermark;
|
|
2727
|
+
branches: Watermark;
|
|
2728
|
+
lines: Watermark;
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2606
2731
|
declare type WithAsymmetricMatcher<T> = T | AsymmetricMatcher<unknown>;
|
|
2607
2732
|
|
|
2608
2733
|
declare type WorkerContext = {
|
|
@@ -2618,4 +2743,24 @@ declare type XInput = {
|
|
|
2618
2743
|
x_google_ignoreList?: SourceMapV3['ignoreList'];
|
|
2619
2744
|
};
|
|
2620
2745
|
|
|
2746
|
+
declare interface XmlWriter {
|
|
2747
|
+
indent(str: string): string;
|
|
2748
|
+
/**
|
|
2749
|
+
* writes the opening XML tag with the supplied attributes
|
|
2750
|
+
*/
|
|
2751
|
+
openTag(name: string, attrs?: any): void;
|
|
2752
|
+
/**
|
|
2753
|
+
* closes an open XML tag.
|
|
2754
|
+
*/
|
|
2755
|
+
closeTag(name: string): void;
|
|
2756
|
+
/**
|
|
2757
|
+
* writes a tag and its value opening and closing it at the same time
|
|
2758
|
+
*/
|
|
2759
|
+
inlineTag(name: string, attrs?: any, content?: string): void;
|
|
2760
|
+
/**
|
|
2761
|
+
* closes all open tags and ends the document
|
|
2762
|
+
*/
|
|
2763
|
+
closeAll(): void;
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2621
2766
|
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@types/chai": "^5.2.3",
|
|
50
|
-
"@rsbuild/core": "1.
|
|
50
|
+
"@rsbuild/core": "1.7.0-beta.0",
|
|
51
51
|
"tinypool": "^1.1.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"@types/babel__code-frame": "^7.0.6",
|
|
65
65
|
"@types/istanbul-reports": "^3.0.4",
|
|
66
66
|
"@types/istanbul-lib-coverage": "^2.0.6",
|
|
67
|
+
"@types/istanbul-lib-report": "^3.0.3",
|
|
67
68
|
"@types/jsdom": "^21.1.7",
|
|
68
69
|
"@types/sinonjs__fake-timers": "^8.1.5",
|
|
69
70
|
"@types/source-map-support": "^0.5.10",
|
|
File without changes
|