@rstest/core 0.8.0 → 0.8.2
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/LICENSE.md +0 -200
- package/dist/0~130.js +7 -9
- package/dist/0~1472.js +8 -12
- package/dist/0~2173.js +102 -67
- package/dist/0~2255.js +2 -2
- package/dist/0~3919.js +1 -1
- package/dist/0~4403.js +4 -4
- package/dist/0~5835.js +3 -3
- package/dist/0~6588.js +4 -7
- package/dist/0~6923.js +3 -3
- package/dist/0~7583.js +8 -9
- package/dist/0~7882.js +36 -723
- package/dist/0~8426.js +5 -7
- package/dist/0~89.js +21 -18
- package/dist/0~9348.js +1 -2
- package/dist/0~9634.js +24 -13
- package/dist/1157.js +172 -42
- package/dist/1157.js.LICENSE.txt +21 -0
- package/dist/1294.js +1 -1
- package/dist/{2672.js → 3160.js} +312 -8
- package/dist/487.js +3 -3
- package/dist/5734.js +2 -5
- package/dist/6151.js +210 -11
- package/dist/6973.js +5 -7
- package/dist/7011.js +19 -0
- package/dist/9131.js +1381 -71
- package/dist/browser-runtime/2~907.js +0 -2
- package/dist/browser-runtime/389.js +628 -24
- package/dist/browser-runtime/index.d.ts +263 -118
- package/dist/browser-runtime/rslib-runtime.js +0 -2
- package/dist/browser.d.ts +324 -119
- package/dist/browser.js +2 -7
- package/dist/globalSetupWorker.js +2 -4
- package/dist/index.d.ts +274 -117
- package/dist/mockRuntimeCode.js +92 -0
- package/dist/rslib-runtime.js +0 -27
- package/dist/worker.d.ts +99 -110
- package/dist/worker.js +3 -5
- package/package.json +2 -3
- package/dist/3278.js +0 -318
- package/dist/browser-runtime/2~907.js.map +0 -1
- package/dist/browser-runtime/389.js.map +0 -1
- package/dist/browser-runtime/rslib-runtime.js.map +0 -1
package/dist/browser.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { assert as assert_2 } from 'chai';
|
|
2
|
-
import color from 'picocolors';
|
|
3
2
|
import type { config } from 'chai';
|
|
3
|
+
import { createColors } from 'picocolors';
|
|
4
4
|
import { Logger } from 'rslog';
|
|
5
5
|
import * as rsbuild from '@rsbuild/core';
|
|
6
6
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
7
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
7
8
|
import type { Writable } from 'node:stream';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -340,6 +341,14 @@ export declare interface BrowserTestRunOptions {
|
|
|
340
341
|
* This allows the caller to unify reporter output with node mode tests.
|
|
341
342
|
*/
|
|
342
343
|
skipOnTestRunEnd?: boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Pre-calculated sharded entries for browser projects.
|
|
346
|
+
* If provided, the browser controller will use these instead of collecting its own.
|
|
347
|
+
* Key is project environmentName.
|
|
348
|
+
*/
|
|
349
|
+
shardedEntries?: Map<string, {
|
|
350
|
+
entries: Record<string, string>;
|
|
351
|
+
}>;
|
|
343
352
|
}
|
|
344
353
|
|
|
345
354
|
/**
|
|
@@ -360,11 +369,14 @@ export declare interface BrowserTestRunResult {
|
|
|
360
369
|
hasFailure: boolean;
|
|
361
370
|
}
|
|
362
371
|
|
|
363
|
-
declare type BuiltInReporterNames =
|
|
372
|
+
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit';
|
|
364
373
|
|
|
365
374
|
declare type BuiltinReporterOptions = {
|
|
366
375
|
default: DefaultReporterOptions;
|
|
367
376
|
verbose: VerboseReporterOptions;
|
|
377
|
+
md: MdReporterOptions;
|
|
378
|
+
'github-actions': Record<string, unknown>;
|
|
379
|
+
junit: Record<string, unknown>;
|
|
368
380
|
};
|
|
369
381
|
|
|
370
382
|
declare type ChaiConfig = Partial<Omit<typeof config, 'useProxy' | 'proxyExcludedKeys' | 'deepEqual'>>;
|
|
@@ -373,7 +385,10 @@ declare interface CloverOptions extends FileOptions, ProjectOptions {}
|
|
|
373
385
|
|
|
374
386
|
declare interface CoberturaOptions extends FileOptions, ProjectOptions {}
|
|
375
387
|
|
|
376
|
-
|
|
388
|
+
/**
|
|
389
|
+
* Create a picocolors instance using default runtime detection.
|
|
390
|
+
*/
|
|
391
|
+
export declare const color: ReturnType<typeof createColors>;
|
|
377
392
|
|
|
378
393
|
/**
|
|
379
394
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -427,6 +442,8 @@ declare interface Constructable {
|
|
|
427
442
|
new (...args: any[]): any;
|
|
428
443
|
}
|
|
429
444
|
|
|
445
|
+
declare type Constructor<T = any> = new (...args: any[]) => T;
|
|
446
|
+
|
|
430
447
|
/**
|
|
431
448
|
* Base class for writing content
|
|
432
449
|
*/
|
|
@@ -499,6 +516,18 @@ declare interface Coverage {
|
|
|
499
516
|
coverage: number;
|
|
500
517
|
}
|
|
501
518
|
|
|
519
|
+
declare class CoverageMap {
|
|
520
|
+
constructor(data: CoverageMapData | CoverageMap);
|
|
521
|
+
addFileCoverage(pathOrObject: string | FileCoverage | FileCoverageData): void;
|
|
522
|
+
files(): string[];
|
|
523
|
+
fileCoverageFor(filename: string): FileCoverage;
|
|
524
|
+
filter(callback: (key: string) => boolean): void;
|
|
525
|
+
getCoverageSummary(): CoverageSummary;
|
|
526
|
+
merge(data: CoverageMapData | CoverageMap): void;
|
|
527
|
+
toJSON(): CoverageMapData;
|
|
528
|
+
data: CoverageMapData;
|
|
529
|
+
}
|
|
530
|
+
|
|
502
531
|
declare interface CoverageMapData {
|
|
503
532
|
[key: string]: FileCoverage | FileCoverageData;
|
|
504
533
|
}
|
|
@@ -573,6 +602,37 @@ declare type CoverageOptions = {
|
|
|
573
602
|
reportOnFailure?: boolean;
|
|
574
603
|
};
|
|
575
604
|
|
|
605
|
+
declare class CoverageProvider {
|
|
606
|
+
constructor(options: CoverageOptions);
|
|
607
|
+
/**
|
|
608
|
+
* Initialize coverage collection
|
|
609
|
+
*/
|
|
610
|
+
init(): void;
|
|
611
|
+
/**
|
|
612
|
+
* Collect coverage data from global coverage object
|
|
613
|
+
*/
|
|
614
|
+
collect(): CoverageMap | null;
|
|
615
|
+
/**
|
|
616
|
+
* Create a new coverage map
|
|
617
|
+
*/
|
|
618
|
+
createCoverageMap(): CoverageMap;
|
|
619
|
+
/**
|
|
620
|
+
* Generate coverage for untested files
|
|
621
|
+
*/
|
|
622
|
+
generateCoverageForUntestedFiles(params: {
|
|
623
|
+
environmentName: string;
|
|
624
|
+
files: string[];
|
|
625
|
+
}): Promise<FileCoverageData[]>;
|
|
626
|
+
/**
|
|
627
|
+
* Generate coverage reports
|
|
628
|
+
*/
|
|
629
|
+
generateReports(coverageMap: CoverageMap, options: CoverageOptions): Promise<void>;
|
|
630
|
+
/**
|
|
631
|
+
* Clean up coverage data
|
|
632
|
+
*/
|
|
633
|
+
cleanup(): void;
|
|
634
|
+
}
|
|
635
|
+
|
|
576
636
|
declare class CoverageSummary {
|
|
577
637
|
constructor(data: CoverageSummary | CoverageSummaryData);
|
|
578
638
|
merge(obj: CoverageSummary): CoverageSummary;
|
|
@@ -664,40 +724,6 @@ declare class DefaultMap<
|
|
|
664
724
|
get(key: K): V;
|
|
665
725
|
}
|
|
666
726
|
|
|
667
|
-
declare class DefaultReporter implements Reporter {
|
|
668
|
-
protected rootPath: string;
|
|
669
|
-
protected config: NormalizedConfig;
|
|
670
|
-
private options;
|
|
671
|
-
protected statusRenderer: StatusRenderer | undefined;
|
|
672
|
-
private testState;
|
|
673
|
-
constructor({ rootPath, options, config, testState, }: {
|
|
674
|
-
rootPath: string;
|
|
675
|
-
config: NormalizedConfig;
|
|
676
|
-
options: DefaultReporterOptions;
|
|
677
|
-
testState: RstestTestState;
|
|
678
|
-
});
|
|
679
|
-
/**
|
|
680
|
-
* Lazily create StatusRenderer on first test file start.
|
|
681
|
-
* This avoids intercepting stdout/stderr before tests actually begin,
|
|
682
|
-
* ensuring early errors (like missing Playwright browsers) remain visible.
|
|
683
|
-
*/
|
|
684
|
-
private ensureStatusRenderer;
|
|
685
|
-
onTestFileStart(): void;
|
|
686
|
-
onTestFileResult(test: TestFileResult): void;
|
|
687
|
-
onTestCaseResult(): void;
|
|
688
|
-
onUserConsoleLog(log: UserConsoleLog): void;
|
|
689
|
-
onExit(): Promise<void>;
|
|
690
|
-
onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, unhandledErrors, }: {
|
|
691
|
-
results: TestFileResult[];
|
|
692
|
-
testResults: TestResult[];
|
|
693
|
-
duration: Duration;
|
|
694
|
-
snapshotSummary: SnapshotSummary;
|
|
695
|
-
getSourcemap: GetSourcemap;
|
|
696
|
-
unhandledErrors?: Error[];
|
|
697
|
-
filterRerunTestPaths?: string[];
|
|
698
|
-
}): Promise<void>;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
727
|
declare type DefaultReporterOptions = {
|
|
702
728
|
/**
|
|
703
729
|
* prints out summary of all tests
|
|
@@ -1032,26 +1058,6 @@ export declare const getTestEntries: ({ include, exclude, rootPath, projectRoot,
|
|
|
1032
1058
|
projectRoot: string;
|
|
1033
1059
|
}) => Promise<Record<string, string>>;
|
|
1034
1060
|
|
|
1035
|
-
declare class GithubActionsReporter {
|
|
1036
|
-
private onWritePath;
|
|
1037
|
-
private rootPath;
|
|
1038
|
-
constructor({ options, rootPath, }: {
|
|
1039
|
-
rootPath: string;
|
|
1040
|
-
options: {
|
|
1041
|
-
onWritePath: (path: string) => string;
|
|
1042
|
-
};
|
|
1043
|
-
});
|
|
1044
|
-
private log;
|
|
1045
|
-
onTestRunEnd({ results, testResults, getSourcemap, }: {
|
|
1046
|
-
results: TestFileResult[];
|
|
1047
|
-
testResults: TestResult[];
|
|
1048
|
-
duration: Duration;
|
|
1049
|
-
snapshotSummary: SnapshotSummary;
|
|
1050
|
-
getSourcemap: GetSourcemap;
|
|
1051
|
-
filterRerunTestPaths?: string[];
|
|
1052
|
-
}): Promise<void>;
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
1061
|
export declare const globalApis: (keyof Rstest_2)[];
|
|
1056
1062
|
|
|
1057
1063
|
declare interface HtmlOptions {
|
|
@@ -1483,28 +1489,6 @@ declare type JsonOptions = FileOptions;
|
|
|
1483
1489
|
|
|
1484
1490
|
declare type JsonSummaryOptions = FileOptions;
|
|
1485
1491
|
|
|
1486
|
-
declare class JUnitReporter implements Reporter {
|
|
1487
|
-
private rootPath;
|
|
1488
|
-
private outputPath?;
|
|
1489
|
-
constructor({ rootPath, options: { outputPath }, }: {
|
|
1490
|
-
rootPath: string;
|
|
1491
|
-
options?: {
|
|
1492
|
-
outputPath?: string;
|
|
1493
|
-
};
|
|
1494
|
-
});
|
|
1495
|
-
private sanitizeXml;
|
|
1496
|
-
private escapeXml;
|
|
1497
|
-
private createJUnitTestCase;
|
|
1498
|
-
private createJUnitTestSuite;
|
|
1499
|
-
private generateJUnitXml;
|
|
1500
|
-
onTestRunEnd({ results, testResults, duration, getSourcemap, }: {
|
|
1501
|
-
getSourcemap: GetSourcemap;
|
|
1502
|
-
results: TestFileResult[];
|
|
1503
|
-
testResults: TestResult[];
|
|
1504
|
-
duration: Duration;
|
|
1505
|
-
}): Promise<void>;
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
1492
|
declare interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
|
|
1509
1493
|
|
|
1510
1494
|
declare interface LcovOptions extends FileOptions, ProjectOptions {}
|
|
@@ -1522,6 +1506,11 @@ export declare type ListCommandResult = {
|
|
|
1522
1506
|
errors?: FormattedError[];
|
|
1523
1507
|
};
|
|
1524
1508
|
|
|
1509
|
+
export declare const loadCoverageProvider: (options: CoverageOptions, root: string) => Promise<{
|
|
1510
|
+
CoverageProvider: typeof CoverageProvider;
|
|
1511
|
+
pluginCoverage: (options: CoverageOptions) => RsbuildPlugin;
|
|
1512
|
+
}>;
|
|
1513
|
+
|
|
1525
1514
|
declare type Location_2 = {
|
|
1526
1515
|
line: number;
|
|
1527
1516
|
column: number;
|
|
@@ -1590,8 +1579,103 @@ declare interface MatcherState_2 extends MatcherState {
|
|
|
1590
1579
|
snapshotState: SnapshotState;
|
|
1591
1580
|
}
|
|
1592
1581
|
|
|
1582
|
+
declare type MaybeMockedDeep<T> = T extends Constructor ? MockedClass<T> : T extends MockProcedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
|
1583
|
+
|
|
1584
|
+
declare type MaybePartiallyMocked<T> = T extends Constructor ? MockedClass<T> : T extends MockProcedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
1585
|
+
|
|
1586
|
+
declare type MaybePartiallyMockedDeep<T> = T extends Constructor ? MockedClass<T> : T extends MockProcedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
|
1587
|
+
|
|
1593
1588
|
declare type MaybePromise<T> = T | Promise<T>;
|
|
1594
1589
|
|
|
1590
|
+
declare type MdReporterOptions = {
|
|
1591
|
+
/**
|
|
1592
|
+
* Output detail level preset.
|
|
1593
|
+
* - `'normal'`: balanced output with code frames, repro commands, and candidate files
|
|
1594
|
+
* - `'compact'`: minimal output without code frames, candidate files, or full stack traces
|
|
1595
|
+
* - `'full'`: verbose output including console logs and environment info
|
|
1596
|
+
* @default 'normal'
|
|
1597
|
+
*/
|
|
1598
|
+
preset?: 'normal' | 'compact' | 'full';
|
|
1599
|
+
/**
|
|
1600
|
+
* Header section controls.
|
|
1601
|
+
* - `false`: omit all header extras (runtime/env)
|
|
1602
|
+
* - `true`: include all default header extras
|
|
1603
|
+
* - object form: toggle individual parts
|
|
1604
|
+
* @default { env: true }
|
|
1605
|
+
*/
|
|
1606
|
+
header?: boolean | {
|
|
1607
|
+
env?: boolean;
|
|
1608
|
+
};
|
|
1609
|
+
/**
|
|
1610
|
+
* Reproduction command controls.
|
|
1611
|
+
* - `false`: omit reproduction commands
|
|
1612
|
+
* - `'file'`: only include the test file path
|
|
1613
|
+
* - `'file+name'`: include both file path and `--testNamePattern`
|
|
1614
|
+
* - `true`: same as `'file+name'`
|
|
1615
|
+
* @default 'file+name'
|
|
1616
|
+
*/
|
|
1617
|
+
reproduction?: boolean | 'file' | 'file+name';
|
|
1618
|
+
/**
|
|
1619
|
+
* Failure output controls.
|
|
1620
|
+
* @default { max: 50 }
|
|
1621
|
+
*/
|
|
1622
|
+
failures?: {
|
|
1623
|
+
max?: number;
|
|
1624
|
+
};
|
|
1625
|
+
/**
|
|
1626
|
+
* Code frame controls.
|
|
1627
|
+
* - `false`: disable code frames
|
|
1628
|
+
* - `true`: enable with default line window
|
|
1629
|
+
* - object form: customize line window
|
|
1630
|
+
* @default { linesAbove: 2, linesBelow: 2 }
|
|
1631
|
+
*/
|
|
1632
|
+
codeFrame?: boolean | {
|
|
1633
|
+
linesAbove?: number;
|
|
1634
|
+
linesBelow?: number;
|
|
1635
|
+
};
|
|
1636
|
+
/**
|
|
1637
|
+
* Stack output controls.
|
|
1638
|
+
* - `false`: omit stack info
|
|
1639
|
+
* - `'top'`: include only the top frame
|
|
1640
|
+
* - `number`: include up to N stack frames
|
|
1641
|
+
* - `'full'`: include a large default number of stack frames
|
|
1642
|
+
* @default 'top'
|
|
1643
|
+
*/
|
|
1644
|
+
stack?: number | false | 'full' | 'top';
|
|
1645
|
+
/**
|
|
1646
|
+
* Candidate files controls (best-effort files extracted from stack traces).
|
|
1647
|
+
* - `false`: omit candidate files
|
|
1648
|
+
* - `true`: enable with defaults
|
|
1649
|
+
* - object form: customize max items
|
|
1650
|
+
* @default { max: 5 }
|
|
1651
|
+
*/
|
|
1652
|
+
candidateFiles?: boolean | {
|
|
1653
|
+
max?: number;
|
|
1654
|
+
};
|
|
1655
|
+
/**
|
|
1656
|
+
* Console output controls.
|
|
1657
|
+
* - `false`: omit console logs
|
|
1658
|
+
* - `true`: include console logs with defaults
|
|
1659
|
+
* - object form: customize limits
|
|
1660
|
+
* @default { maxLogsPerTestPath: 10, maxCharsPerEntry: 500 }
|
|
1661
|
+
*/
|
|
1662
|
+
console?: boolean | {
|
|
1663
|
+
maxLogsPerTestPath?: number;
|
|
1664
|
+
maxCharsPerEntry?: number;
|
|
1665
|
+
};
|
|
1666
|
+
/**
|
|
1667
|
+
* Error section controls.
|
|
1668
|
+
* @default { unhandled: true }
|
|
1669
|
+
*/
|
|
1670
|
+
errors?: boolean | {
|
|
1671
|
+
unhandled?: boolean;
|
|
1672
|
+
};
|
|
1673
|
+
};
|
|
1674
|
+
|
|
1675
|
+
declare type Methods<T> = {
|
|
1676
|
+
[K in keyof T]: T[K] extends MockProcedure ? K : never;
|
|
1677
|
+
}[keyof T];
|
|
1678
|
+
|
|
1595
1679
|
export declare interface Mock<T extends FunctionLike = FunctionLike> extends MockInstance_2<T> {
|
|
1596
1680
|
new (...args: Parameters<T>): ReturnType<T>;
|
|
1597
1681
|
(...args: Parameters<T>): ReturnType<T>;
|
|
@@ -1740,6 +1824,31 @@ declare type MockContext_2<T extends FunctionLike = FunctionLike> = {
|
|
|
1740
1824
|
settledResults: MockSettledResult_2<Awaited<ReturnType<T>>>[];
|
|
1741
1825
|
};
|
|
1742
1826
|
|
|
1827
|
+
export declare type Mocked<T> = T extends Constructor ? MockedClass<T> : T extends MockProcedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
1828
|
+
|
|
1829
|
+
declare type MockedClass<T extends Constructor> = Mock<(...args: ConstructorParameters<T>) => InstanceType<T>> & {
|
|
1830
|
+
new (...args: ConstructorParameters<T>): InstanceType<T>;
|
|
1831
|
+
prototype: InstanceType<T>;
|
|
1832
|
+
};
|
|
1833
|
+
|
|
1834
|
+
declare type MockedFunction<T extends MockProcedure> = Mock<T> & {
|
|
1835
|
+
[K in keyof T]: T[K];
|
|
1836
|
+
};
|
|
1837
|
+
|
|
1838
|
+
declare type MockedFunctionDeep<T extends MockProcedure> = Mock<T> & MockedObjectDeep<T>;
|
|
1839
|
+
|
|
1840
|
+
declare type MockedObject<T> = {
|
|
1841
|
+
[K in Methods<T>]: T[K] extends MockProcedure ? MockedFunction<T[K]> : T[K];
|
|
1842
|
+
} & {
|
|
1843
|
+
[K in Properties<T>]: T[K];
|
|
1844
|
+
};
|
|
1845
|
+
|
|
1846
|
+
declare type MockedObjectDeep<T> = {
|
|
1847
|
+
[K in Methods<T>]: T[K] extends MockProcedure ? MockedFunctionDeep<T[K]> : T[K];
|
|
1848
|
+
} & {
|
|
1849
|
+
[K in Properties<T>]: MaybeMockedDeep<T[K]>;
|
|
1850
|
+
};
|
|
1851
|
+
|
|
1743
1852
|
declare type MockFactory<T = unknown> = () => MaybePromise<Partial<T>>;
|
|
1744
1853
|
|
|
1745
1854
|
declare type MockFn = <T extends FunctionLike = FunctionLike>(fn?: T) => Mock<T>;
|
|
@@ -1966,6 +2075,37 @@ declare interface MockInstance_2<T extends FunctionLike = FunctionLike> {
|
|
|
1966
2075
|
mockRejectedValueOnce(error: unknown): this;
|
|
1967
2076
|
}
|
|
1968
2077
|
|
|
2078
|
+
/**
|
|
2079
|
+
* Options for rs.mock module mocking.
|
|
2080
|
+
* Supports `{ spy: true }` or `{ mock: true }`.
|
|
2081
|
+
*/
|
|
2082
|
+
declare type MockModuleOptions = {
|
|
2083
|
+
/**
|
|
2084
|
+
* If `true`, the module will be auto-mocked but the original implementations
|
|
2085
|
+
* will be preserved - all exports will be wrapped in spy functions that track calls.
|
|
2086
|
+
*/
|
|
2087
|
+
spy: true;
|
|
2088
|
+
} | {
|
|
2089
|
+
/**
|
|
2090
|
+
* If `true`, the module will be auto-mocked with all exports replaced by mock functions.
|
|
2091
|
+
* Original implementations will NOT be preserved.
|
|
2092
|
+
*/
|
|
2093
|
+
mock: true;
|
|
2094
|
+
};
|
|
2095
|
+
|
|
2096
|
+
/**
|
|
2097
|
+
* Options for mockObject
|
|
2098
|
+
*/
|
|
2099
|
+
declare interface MockOptions {
|
|
2100
|
+
/**
|
|
2101
|
+
* If `true`, the original implementation will be kept.
|
|
2102
|
+
* All methods will call the original implementation, but you can still track the calls.
|
|
2103
|
+
*/
|
|
2104
|
+
spy?: boolean;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
declare type MockProcedure = (...args: any[]) => any;
|
|
2108
|
+
|
|
1969
2109
|
declare type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
|
|
1970
2110
|
|
|
1971
2111
|
declare type MockResult_2<T> = MockResultReturn_2<T> | MockResultThrow_2 | MockResultIncomplete_2;
|
|
@@ -2106,7 +2246,7 @@ export declare const onTestFinished: Rstest_2['onTestFinished'];
|
|
|
2106
2246
|
|
|
2107
2247
|
declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
|
|
2108
2248
|
|
|
2109
|
-
declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends';
|
|
2249
|
+
declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
|
|
2110
2250
|
|
|
2111
2251
|
declare interface Options {
|
|
2112
2252
|
logger: {
|
|
@@ -2181,7 +2321,7 @@ declare type Project = {
|
|
|
2181
2321
|
configFilePath?: string;
|
|
2182
2322
|
};
|
|
2183
2323
|
|
|
2184
|
-
declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'hideSkippedTests' | 'hideSkippedTestFiles' | 'bail'>;
|
|
2324
|
+
declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'hideSkippedTests' | 'hideSkippedTestFiles' | 'bail' | 'shard'>;
|
|
2185
2325
|
|
|
2186
2326
|
export declare type ProjectContext = {
|
|
2187
2327
|
name: string;
|
|
@@ -2209,6 +2349,10 @@ declare type PromisifyAssertion<T> = Promisify<Assertion_2<T>>;
|
|
|
2209
2349
|
|
|
2210
2350
|
declare type PromisifyAssertion_2<T> = Promisify_2<Assertion<T>>;
|
|
2211
2351
|
|
|
2352
|
+
declare type Properties<T> = {
|
|
2353
|
+
[K in keyof T]: T[K] extends MockProcedure ? never : K;
|
|
2354
|
+
}[keyof T];
|
|
2355
|
+
|
|
2212
2356
|
declare interface Range_2 {
|
|
2213
2357
|
start: Location_3;
|
|
2214
2358
|
end: Location_3;
|
|
@@ -2295,13 +2439,6 @@ export declare interface Reporter {
|
|
|
2295
2439
|
onExit?: () => void;
|
|
2296
2440
|
}
|
|
2297
2441
|
|
|
2298
|
-
declare const reportersMap: {
|
|
2299
|
-
default: typeof DefaultReporter;
|
|
2300
|
-
verbose: typeof VerboseReporter;
|
|
2301
|
-
'github-actions': typeof GithubActionsReporter;
|
|
2302
|
-
junit: typeof JUnitReporter;
|
|
2303
|
-
};
|
|
2304
|
-
|
|
2305
2442
|
declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
|
|
2306
2443
|
|
|
2307
2444
|
declare interface ReportOptions {
|
|
@@ -2463,6 +2600,14 @@ declare interface RstestConfig {
|
|
|
2463
2600
|
* @default 0
|
|
2464
2601
|
*/
|
|
2465
2602
|
bail?: number;
|
|
2603
|
+
/**
|
|
2604
|
+
* Split tests into several shards.
|
|
2605
|
+
* This is useful for running tests in parallel on multiple machines.
|
|
2606
|
+
*/
|
|
2607
|
+
shard?: {
|
|
2608
|
+
count: number;
|
|
2609
|
+
index: number;
|
|
2610
|
+
};
|
|
2466
2611
|
/**
|
|
2467
2612
|
* print console traces when calling any console method.
|
|
2468
2613
|
*
|
|
@@ -2660,6 +2805,74 @@ declare interface RstestUtilities {
|
|
|
2660
2805
|
* Determines if the given function is a mocked function.
|
|
2661
2806
|
*/
|
|
2662
2807
|
isMockFunction: (fn: any) => fn is MockInstance_2;
|
|
2808
|
+
/**
|
|
2809
|
+
* Deeply mocks properties and methods of a given object
|
|
2810
|
+
* in the same way as `rstest.mock()` mocks module exports.
|
|
2811
|
+
*
|
|
2812
|
+
* @example
|
|
2813
|
+
* ```ts
|
|
2814
|
+
* const original = {
|
|
2815
|
+
* simple: () => 'value',
|
|
2816
|
+
* nested: {
|
|
2817
|
+
* method: () => 'real'
|
|
2818
|
+
* },
|
|
2819
|
+
* prop: 'foo',
|
|
2820
|
+
* }
|
|
2821
|
+
*
|
|
2822
|
+
* const mocked = rstest.mockObject(original)
|
|
2823
|
+
* expect(mocked.simple()).toBe(undefined)
|
|
2824
|
+
* expect(mocked.nested.method()).toBe(undefined)
|
|
2825
|
+
* expect(mocked.prop).toBe('foo')
|
|
2826
|
+
*
|
|
2827
|
+
* mocked.simple.mockReturnValue('mocked')
|
|
2828
|
+
* expect(mocked.simple()).toBe('mocked')
|
|
2829
|
+
*
|
|
2830
|
+
* // With spy option to keep original implementations
|
|
2831
|
+
* const spied = rstest.mockObject(original, { spy: true })
|
|
2832
|
+
* expect(spied.simple()).toBe('value')
|
|
2833
|
+
* expect(spied.simple).toHaveBeenCalled()
|
|
2834
|
+
* ```
|
|
2835
|
+
*
|
|
2836
|
+
* @param value - The object to be mocked
|
|
2837
|
+
* @param options - Mock options
|
|
2838
|
+
* @returns A deeply mocked version of the input object
|
|
2839
|
+
*/
|
|
2840
|
+
mockObject: <T>(value: T, options?: MockOptions) => MaybeMockedDeep<T>;
|
|
2841
|
+
/**
|
|
2842
|
+
* Type helper for TypeScript. Just returns the object that was passed.
|
|
2843
|
+
*
|
|
2844
|
+
* When `partial` is `true` it will expect a `Partial<T>` as a return value.
|
|
2845
|
+
* By default, this will only make TypeScript believe that the first level values are mocked.
|
|
2846
|
+
* You can pass down `{ deep: true }` as a second argument to tell TypeScript
|
|
2847
|
+
* that the whole object is mocked, if it actually is.
|
|
2848
|
+
*
|
|
2849
|
+
* @example
|
|
2850
|
+
* ```ts
|
|
2851
|
+
* import example from './example.js'
|
|
2852
|
+
*
|
|
2853
|
+
* rstest.mock('./example.js')
|
|
2854
|
+
*
|
|
2855
|
+
* test('1 + 1 equals 10', async () => {
|
|
2856
|
+
* rstest.mocked(example.calc).mockReturnValue(10)
|
|
2857
|
+
* expect(example.calc(1, '+', 1)).toBe(10)
|
|
2858
|
+
* })
|
|
2859
|
+
* ```
|
|
2860
|
+
* @param item - Anything that can be mocked
|
|
2861
|
+
* @returns The same item with mocked type
|
|
2862
|
+
*/
|
|
2863
|
+
mocked: (<T>(item: T, deep?: false) => Mocked<T>) & (<T>(item: T, deep: true) => MaybeMockedDeep<T>) & (<T>(item: T, options: {
|
|
2864
|
+
partial?: false;
|
|
2865
|
+
deep?: false;
|
|
2866
|
+
}) => Mocked<T>) & (<T>(item: T, options: {
|
|
2867
|
+
partial?: false;
|
|
2868
|
+
deep: true;
|
|
2869
|
+
}) => MaybeMockedDeep<T>) & (<T>(item: T, options: {
|
|
2870
|
+
partial: true;
|
|
2871
|
+
deep?: false;
|
|
2872
|
+
}) => MaybePartiallyMocked<T>) & (<T>(item: T, options: {
|
|
2873
|
+
partial: true;
|
|
2874
|
+
deep: true;
|
|
2875
|
+
}) => MaybePartiallyMockedDeep<T>);
|
|
2663
2876
|
/**
|
|
2664
2877
|
* Calls `.mockClear()` on all spies.
|
|
2665
2878
|
*/
|
|
@@ -2673,21 +2886,37 @@ declare interface RstestUtilities {
|
|
|
2673
2886
|
*/
|
|
2674
2887
|
restoreAllMocks: () => RstestUtilities;
|
|
2675
2888
|
/**
|
|
2676
|
-
* Mock a module
|
|
2889
|
+
* Mock a module.
|
|
2890
|
+
*
|
|
2891
|
+
* When called with a factory function, the module will be replaced with the return value of the factory.
|
|
2892
|
+
* When called with `{ spy: true }`, the module will be auto-mocked but the original implementations
|
|
2893
|
+
* will be preserved - all exports will be wrapped in spy functions that track calls.
|
|
2894
|
+
*
|
|
2895
|
+
* @example
|
|
2896
|
+
* ```ts
|
|
2897
|
+
* // Replace module with factory
|
|
2898
|
+
* rs.mock('./module', () => ({ fn: rs.fn() }))
|
|
2899
|
+
*
|
|
2900
|
+
* // Auto-mock with spy mode - keeps original implementations
|
|
2901
|
+
* rs.mock('./module', { spy: true })
|
|
2902
|
+
* ```
|
|
2677
2903
|
*/
|
|
2678
|
-
mock<T = unknown>(moduleName: string | Promise<T>,
|
|
2904
|
+
mock<T = unknown>(moduleName: string | Promise<T>, factoryOrOptions?: MockFactory<T> | MockModuleOptions): void;
|
|
2679
2905
|
/**
|
|
2680
|
-
* Mock a module
|
|
2906
|
+
* Mock a module (CommonJS require)
|
|
2681
2907
|
*/
|
|
2682
|
-
mockRequire: <T = unknown>(moduleName: string,
|
|
2908
|
+
mockRequire: <T = unknown>(moduleName: string, factoryOrOptions?: (() => T) | MockModuleOptions) => void;
|
|
2683
2909
|
/**
|
|
2684
2910
|
* Mock a module, not hoisted.
|
|
2911
|
+
*
|
|
2912
|
+
* When called with `{ spy: true }`, the module will be auto-mocked but the original implementations
|
|
2913
|
+
* will be preserved - all exports will be wrapped in spy functions that track calls.
|
|
2685
2914
|
*/
|
|
2686
|
-
doMock<T = unknown>(moduleName: string | Promise<T>,
|
|
2915
|
+
doMock<T = unknown>(moduleName: string | Promise<T>, factoryOrOptions?: MockFactory<T> | MockModuleOptions): void;
|
|
2687
2916
|
/**
|
|
2688
|
-
* Mock a module, not hoisted.
|
|
2917
|
+
* Mock a module, not hoisted (CommonJS require).
|
|
2689
2918
|
*/
|
|
2690
|
-
doMockRequire: <T = unknown>(moduleName: string,
|
|
2919
|
+
doMockRequire: <T = unknown>(moduleName: string, factoryOrOptions?: (() => T) | MockModuleOptions) => void;
|
|
2691
2920
|
/**
|
|
2692
2921
|
* Hoisted mock function.
|
|
2693
2922
|
*/
|
|
@@ -3017,19 +3246,6 @@ declare interface SourceMapV3 {
|
|
|
3017
3246
|
|
|
3018
3247
|
declare type SourcesIndex = number;
|
|
3019
3248
|
|
|
3020
|
-
declare class StatusRenderer {
|
|
3021
|
-
private rootPath;
|
|
3022
|
-
private renderer;
|
|
3023
|
-
private startTime;
|
|
3024
|
-
private testState;
|
|
3025
|
-
constructor(rootPath: string, state: RstestTestState, logger?: Options['logger']);
|
|
3026
|
-
getContent(): string[];
|
|
3027
|
-
onTestFileStart(): void;
|
|
3028
|
-
onTestCaseResult(): void;
|
|
3029
|
-
onTestFileResult(): void;
|
|
3030
|
-
clear(): void;
|
|
3031
|
-
}
|
|
3032
|
-
|
|
3033
3249
|
declare function stringify(object: unknown, maxDepth?: number, { maxLength,...options }?: StringifyOptions): string;
|
|
3034
3250
|
|
|
3035
3251
|
declare interface StringifyOptions extends PrettyFormatOptions {
|
|
@@ -3314,17 +3530,6 @@ export declare interface UserConsoleLog {
|
|
|
3314
3530
|
type: 'stdout' | 'stderr';
|
|
3315
3531
|
}
|
|
3316
3532
|
|
|
3317
|
-
declare class VerboseReporter extends DefaultReporter {
|
|
3318
|
-
private verboseOptions;
|
|
3319
|
-
constructor({ rootPath, options, config, testState, }: {
|
|
3320
|
-
rootPath: string;
|
|
3321
|
-
config: NormalizedConfig;
|
|
3322
|
-
options: VerboseReporterOptions;
|
|
3323
|
-
testState: RstestTestState;
|
|
3324
|
-
});
|
|
3325
|
-
onTestFileResult(test: TestFileResult): void;
|
|
3326
|
-
}
|
|
3327
|
-
|
|
3328
3533
|
declare type VerboseReporterOptions = Omit<DefaultReporterOptions, 'summary'>;
|
|
3329
3534
|
|
|
3330
3535
|
declare interface Visitor<N extends Node_2 = Node_2> {
|
package/dist/browser.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
5
|
-
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
6
|
-
var picocolors_default_0 = picocolors_default();
|
|
7
3
|
export { TEMP_RSTEST_OUTPUT_DIR, getTestEntries, globalApis } from "./1157.js";
|
|
8
4
|
export { afterAll, afterEach, assert, beforeAll, beforeEach, describe, expect, it, onTestFailed, onTestFinished, rs, rsbuild, rstest, test } from "./4484.js";
|
|
5
|
+
export { color, isDebug, logger, serializableConfig } from "./3160.js";
|
|
9
6
|
export { createRstestRuntime } from "./6151.js";
|
|
10
7
|
export { getSetupFiles } from "./6973.js";
|
|
11
|
-
export {
|
|
12
|
-
export { serializableConfig } from "./2672.js";
|
|
8
|
+
export { loadCoverageProvider } from "./5734.js";
|
|
13
9
|
export { setRealTimers } from "./1294.js";
|
|
14
|
-
export { picocolors_default_0 as color };
|
|
@@ -2,11 +2,9 @@ import 'module';
|
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
4
|
import "./487.js";
|
|
5
|
-
import "./
|
|
5
|
+
import { color } from "./3160.js";
|
|
6
6
|
import { formatTestError } from "./1294.js";
|
|
7
7
|
const source_map_support = __webpack_require__("../../node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/source-map-support.js");
|
|
8
|
-
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
9
|
-
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
10
8
|
let teardownCallbacks = [];
|
|
11
9
|
let initialEnv = {};
|
|
12
10
|
let envChanges = {};
|
|
@@ -108,7 +106,7 @@ const runGlobalTeardown = async ()=>{
|
|
|
108
106
|
};
|
|
109
107
|
} catch (error) {
|
|
110
108
|
const message = error instanceof Error && error.stack ? error.stack : String(error);
|
|
111
|
-
console.error(
|
|
109
|
+
console.error(color.red(`Error during global teardown: ${message}`));
|
|
112
110
|
return {
|
|
113
111
|
success: false
|
|
114
112
|
};
|