@rstest/core 0.9.4 → 0.9.6
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 +54 -202
- package/dist/0~8843.js +32 -14
- package/dist/{0~lib.js → 0~@babel/code-frame.js} +2 -2
- package/dist/0~@clack/prompts.js +1044 -0
- package/dist/0~browserLoader.js +1 -1
- package/dist/0~browser~1.js +19 -19
- package/dist/0~checkThresholds.js +2 -2
- package/dist/0~chokidar.js +43 -42
- package/dist/0~console.js +1 -1
- package/dist/0~fake-timers.js +1586 -0
- package/dist/0~generate.js +5 -5
- package/dist/0~happyDom.js +1 -1
- package/dist/0~jsdom.js +1 -1
- package/dist/0~listTests.js +3 -3
- package/dist/0~loadModule.js +1 -1
- package/dist/0~magic-string.es.js +1 -181
- package/dist/0~restart.js +1 -1
- package/dist/0~runTests.js +11 -4
- package/dist/0~snapshot.js +2140 -0
- package/dist/0~snapshot.js.LICENSE.txt +7 -0
- package/dist/0~utils.js +1 -1
- package/dist/1255.js +11 -11
- package/dist/1949.js +2919 -9808
- package/dist/1949.js.LICENSE.txt +1 -49
- package/dist/3145.js +415 -40
- package/dist/4411.js +245 -60
- package/dist/6830.js +62 -10
- package/dist/6887.js +15 -0
- package/dist/7552.js +22 -4918
- package/dist/9743.js +1982 -0
- package/dist/9784.js +1343 -0
- package/dist/{7552.js.LICENSE.txt → 9784.js.LICENSE.txt} +19 -8
- package/dist/browser-runtime/2~fake-timers.js +1760 -0
- package/dist/browser-runtime/2~magic-string.es.js +3 -189
- package/dist/browser-runtime/2~snapshot.js +2138 -0
- package/dist/browser-runtime/2~snapshot.js.LICENSE.txt +7 -0
- package/dist/browser-runtime/723.js +1818 -10300
- package/dist/browser-runtime/723.js.LICENSE.txt +0 -17
- package/dist/browser-runtime/index.d.ts +205 -16
- package/dist/browser.d.ts +55 -10
- package/dist/browser.js +2 -2
- package/dist/globalSetupWorker.js +2 -2
- package/dist/index.d.ts +78 -16
- package/dist/index.js +1 -1
- package/dist/mockRuntimeCode.js +2 -0
- package/dist/worker.d.ts +47 -10
- package/dist/worker.js +12 -10
- package/package.json +27 -28
- package/dist/0~dist.js +0 -1014
- package/dist/4899.js +0 -11
- package/dist/browser-runtime/rslib-runtime.js +0 -56
- /package/dist/{rslib-runtime.js → 0~rslib-runtime.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -339,7 +339,7 @@ declare type BrowserViewport = {
|
|
|
339
339
|
height: number;
|
|
340
340
|
} | DevicePreset;
|
|
341
341
|
|
|
342
|
-
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'blob';
|
|
342
|
+
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'json' | 'blob';
|
|
343
343
|
|
|
344
344
|
declare type BuiltinReporterOptions = {
|
|
345
345
|
default: DefaultReporterOptions;
|
|
@@ -347,6 +347,7 @@ declare type BuiltinReporterOptions = {
|
|
|
347
347
|
md: MdReporterOptions;
|
|
348
348
|
'github-actions': Record<string, unknown>;
|
|
349
349
|
junit: Record<string, unknown>;
|
|
350
|
+
json: JsonReporterOptions;
|
|
350
351
|
blob: BlobReporterOptions;
|
|
351
352
|
};
|
|
352
353
|
|
|
@@ -582,11 +583,14 @@ export declare type CoverageOptions = {
|
|
|
582
583
|
* This option accepts an array of wax(https://crates.io/crates/wax)-compatible glob patterns
|
|
583
584
|
*
|
|
584
585
|
* @default ['**\/node_modules/**',
|
|
585
|
-
* '**\/dist/**',
|
|
586
586
|
* '**\/test/**',
|
|
587
587
|
* '**\/__tests__/**',
|
|
588
|
-
* '
|
|
589
|
-
* '
|
|
588
|
+
* '**\/__mocks__/**',
|
|
589
|
+
* '**\/*.d.ts',
|
|
590
|
+
* '**\/*.{test,spec}.[jt]s',
|
|
591
|
+
* '**\/*.{test,spec}.[cm][jt]s',
|
|
592
|
+
* '**\/*.{test,spec}.[jt]sx',
|
|
593
|
+
* '**\/*.{test,spec}.[cm][jt]sx'
|
|
590
594
|
* ]
|
|
591
595
|
*/
|
|
592
596
|
exclude?: string[];
|
|
@@ -789,15 +793,26 @@ export declare function defineConfig(config: RstestConfigAsyncFn): RstestConfigA
|
|
|
789
793
|
export declare function defineConfig(config: RstestConfigExport): RstestConfigExport;
|
|
790
794
|
|
|
791
795
|
/**
|
|
792
|
-
* This function helps you to autocomplete configuration types.
|
|
793
|
-
|
|
796
|
+
* This function helps you to autocomplete inline project configuration types.
|
|
797
|
+
*/
|
|
798
|
+
export declare function defineInlineProject(config: InlineProjectConfig): InlineProjectConfig;
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* This function helps you to autocomplete project configuration types.
|
|
802
|
+
* It accepts an inline or nested Rstest project config object, or a function that returns one.
|
|
794
803
|
*/
|
|
795
|
-
export declare function defineProject(config:
|
|
804
|
+
export declare function defineProject(config: ExportedProjectConfig): ExportedProjectConfig;
|
|
805
|
+
|
|
806
|
+
export declare function defineProject(config: NestedProjectConfig): NestedProjectConfig;
|
|
796
807
|
|
|
797
808
|
export declare function defineProject(config: ProjectConfigSyncFn): ProjectConfigSyncFn;
|
|
798
809
|
|
|
810
|
+
export declare function defineProject(config: NestedProjectConfigSyncFn): NestedProjectConfigSyncFn;
|
|
811
|
+
|
|
799
812
|
export declare function defineProject(config: ProjectConfigAsyncFn): ProjectConfigAsyncFn;
|
|
800
813
|
|
|
814
|
+
export declare function defineProject(config: NestedProjectConfigAsyncFn): NestedProjectConfigAsyncFn;
|
|
815
|
+
|
|
801
816
|
export declare type Describe = DescribeFn & {
|
|
802
817
|
each: DescribeEachFn;
|
|
803
818
|
for: DescribeForFn;
|
|
@@ -943,6 +958,8 @@ declare interface ExpectStatic_2 extends Chai.ExpectStatic, Matchers, Asymmetric
|
|
|
943
958
|
not: AsymmetricMatchersContaining;
|
|
944
959
|
}
|
|
945
960
|
|
|
961
|
+
declare type ExportedProjectConfig = ProjectConfig;
|
|
962
|
+
|
|
946
963
|
export declare type ExtendConfig = Omit<LooseRstestConfig, 'projects'>;
|
|
947
964
|
|
|
948
965
|
export declare type ExtendConfigFn = (userConfig: Readonly<LooseRstestConfig>) => MaybePromise<ExtendConfig>;
|
|
@@ -1551,6 +1568,13 @@ declare interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomM
|
|
|
1551
1568
|
|
|
1552
1569
|
declare type JsonOptions = FileOptions;
|
|
1553
1570
|
|
|
1571
|
+
declare type JsonReporterOptions = {
|
|
1572
|
+
/**
|
|
1573
|
+
* Write report JSON to a file instead of stdout.
|
|
1574
|
+
*/
|
|
1575
|
+
outputPath?: string;
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1554
1578
|
declare type JsonSummaryOptions = FileOptions;
|
|
1555
1579
|
|
|
1556
1580
|
declare interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
|
|
@@ -2262,9 +2286,13 @@ declare interface MockSettledResultRejected_2 {
|
|
|
2262
2286
|
declare type NamesIndex = number;
|
|
2263
2287
|
|
|
2264
2288
|
declare type NestedProjectConfig = {
|
|
2265
|
-
projects: (
|
|
2289
|
+
projects: (InlineProjectConfig | string)[];
|
|
2266
2290
|
};
|
|
2267
2291
|
|
|
2292
|
+
declare type NestedProjectConfigAsyncFn = () => Promise<NestedProjectConfig>;
|
|
2293
|
+
|
|
2294
|
+
declare type NestedProjectConfigSyncFn = () => NestedProjectConfig;
|
|
2295
|
+
|
|
2268
2296
|
declare interface NewPlugin {
|
|
2269
2297
|
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
|
2270
2298
|
test: Test;
|
|
@@ -2286,7 +2314,7 @@ declare type NormalizedBrowserModeConfig = {
|
|
|
2286
2314
|
providerOptions: Record<string, unknown>;
|
|
2287
2315
|
};
|
|
2288
2316
|
|
|
2289
|
-
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
2317
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser' | 'output'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
2290
2318
|
pool: RstestPoolOptions;
|
|
2291
2319
|
testEnvironment: EnvironmentWithOptions;
|
|
2292
2320
|
coverage: NormalizedCoverageOptions;
|
|
@@ -2297,6 +2325,7 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
|
|
|
2297
2325
|
patterns: string[];
|
|
2298
2326
|
override?: boolean;
|
|
2299
2327
|
};
|
|
2328
|
+
output: NormalizedOutputConfig;
|
|
2300
2329
|
};
|
|
2301
2330
|
|
|
2302
2331
|
export declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresholds' | 'include'>> & {
|
|
@@ -2304,13 +2333,20 @@ export declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, '
|
|
|
2304
2333
|
include?: string[];
|
|
2305
2334
|
};
|
|
2306
2335
|
|
|
2336
|
+
declare type NormalizedOutputConfig = Partial<Omit<RstestOutputConfig, 'distPath'>> & {
|
|
2337
|
+
distPath: {
|
|
2338
|
+
root: string;
|
|
2339
|
+
};
|
|
2340
|
+
};
|
|
2341
|
+
|
|
2307
2342
|
declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
|
|
2308
2343
|
|
|
2309
2344
|
declare type NormalizedProcedure_2<T extends Procedure_2> = (...args: Parameters<T>) => ReturnType<T>;
|
|
2310
2345
|
|
|
2311
|
-
declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup'>> & Pick<NormalizedConfig, OptionalKeys> & {
|
|
2346
|
+
declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup' | 'output'>> & Pick<NormalizedConfig, OptionalKeys> & {
|
|
2312
2347
|
setupFiles: string[];
|
|
2313
2348
|
globalSetup: string[];
|
|
2349
|
+
output?: Omit<NormalizedOutputConfig, 'distPath'>;
|
|
2314
2350
|
};
|
|
2315
2351
|
|
|
2316
2352
|
declare interface OldPlugin {
|
|
@@ -2326,7 +2362,7 @@ export declare const onTestFinished: Rstest['onTestFinished'];
|
|
|
2326
2362
|
|
|
2327
2363
|
declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
|
|
2328
2364
|
|
|
2329
|
-
declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | '
|
|
2365
|
+
declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
|
|
2330
2366
|
|
|
2331
2367
|
declare interface Options {
|
|
2332
2368
|
logger: {
|
|
@@ -2393,11 +2429,13 @@ declare type Project = {
|
|
|
2393
2429
|
configFilePath?: string;
|
|
2394
2430
|
};
|
|
2395
2431
|
|
|
2396
|
-
export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'
|
|
2432
|
+
export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard' | 'output'> & {
|
|
2433
|
+
output?: Omit<RstestOutputConfig, 'distPath'>;
|
|
2434
|
+
};
|
|
2397
2435
|
|
|
2398
|
-
declare type ProjectConfigAsyncFn = () => Promise<
|
|
2436
|
+
declare type ProjectConfigAsyncFn = () => Promise<ExportedProjectConfig>;
|
|
2399
2437
|
|
|
2400
|
-
declare type ProjectConfigSyncFn = () =>
|
|
2438
|
+
declare type ProjectConfigSyncFn = () => ExportedProjectConfig;
|
|
2401
2439
|
|
|
2402
2440
|
declare type ProjectContext = {
|
|
2403
2441
|
name: string;
|
|
@@ -2784,9 +2822,9 @@ export declare interface RstestConfig {
|
|
|
2784
2822
|
*/
|
|
2785
2823
|
includeTaskLocation?: boolean;
|
|
2786
2824
|
plugins?: RsbuildConfig['plugins'];
|
|
2787
|
-
source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
|
|
2825
|
+
source?: Pick<NonNullable<RsbuildConfig['source']>, 'assetsInclude' | 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude' | 'transformImport' | 'assetsInclude'>;
|
|
2788
2826
|
dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
|
|
2789
|
-
output?:
|
|
2827
|
+
output?: RstestOutputConfig;
|
|
2790
2828
|
resolve?: RsbuildConfig['resolve'];
|
|
2791
2829
|
tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
|
|
2792
2830
|
}
|
|
@@ -2845,6 +2883,22 @@ declare type RstestInstance = {
|
|
|
2845
2883
|
}) => Promise<void>;
|
|
2846
2884
|
};
|
|
2847
2885
|
|
|
2886
|
+
declare type RstestOutputConfig = Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'> & {
|
|
2887
|
+
distPath?: string | {
|
|
2888
|
+
root?: string;
|
|
2889
|
+
};
|
|
2890
|
+
/**
|
|
2891
|
+
* Whether to bundle third-party dependencies from node_modules.
|
|
2892
|
+
* - `true`: Always bundle all third-party dependencies.
|
|
2893
|
+
* - `false`: Always externalize third-party dependencies.
|
|
2894
|
+
*
|
|
2895
|
+
* When unset, rstest bundles dependencies in browser-like test
|
|
2896
|
+
* environments (jsdom, happy-dom, etc.) and externalizes them in the node
|
|
2897
|
+
* environment. This option is not supported in browser mode.
|
|
2898
|
+
*/
|
|
2899
|
+
bundleDependencies?: boolean;
|
|
2900
|
+
};
|
|
2901
|
+
|
|
2848
2902
|
declare type RstestPoolOptions = {
|
|
2849
2903
|
/** Pool used to run tests in. */
|
|
2850
2904
|
type?: RstestPoolType;
|
|
@@ -2998,10 +3052,18 @@ export declare interface RstestUtilities {
|
|
|
2998
3052
|
* Removes module from the mocked registry.
|
|
2999
3053
|
*/
|
|
3000
3054
|
unmock: (path: string) => void;
|
|
3055
|
+
/**
|
|
3056
|
+
* Removes CommonJS require module from the mocked registry.
|
|
3057
|
+
*/
|
|
3058
|
+
unmockRequire: (path: string) => void;
|
|
3001
3059
|
/**
|
|
3002
3060
|
* Removes module from the mocked registry, not hoisted.
|
|
3003
3061
|
*/
|
|
3004
3062
|
doUnmock: (path: string) => void;
|
|
3063
|
+
/**
|
|
3064
|
+
* Removes CommonJS require module from the mocked registry, not hoisted.
|
|
3065
|
+
*/
|
|
3066
|
+
doUnmockRequire: (path: string) => void;
|
|
3005
3067
|
/**
|
|
3006
3068
|
* Imports a module with all of its properties (including nested properties) mocked.
|
|
3007
3069
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
export { afterAll, afterEach, assert, beforeAll, beforeEach, describe, expect, it, onTestFailed, onTestFinished, rs, rstest, test } from "./5040.js";
|
|
3
|
-
export { createRstest, defineConfig, defineProject, initCli, loadConfig, mergeProjectConfig, mergeRstestConfig, runCLI } from "./3145.js";
|
|
3
|
+
export { createRstest, defineConfig, defineInlineProject, defineProject, initCli, loadConfig, mergeProjectConfig, mergeRstestConfig, runCLI } from "./3145.js";
|
package/dist/mockRuntimeCode.js
CHANGED
|
@@ -28,6 +28,8 @@ __webpack_require__.rstest_unmock = (id)=>{
|
|
|
28
28
|
delete __webpack_module_cache__[id];
|
|
29
29
|
};
|
|
30
30
|
__webpack_require__.rstest_do_unmock = __webpack_require__.rstest_unmock;
|
|
31
|
+
__webpack_require__.rstest_unmock_require = __webpack_require__.rstest_unmock;
|
|
32
|
+
__webpack_require__.rstest_do_unmock_require = __webpack_require__.rstest_do_unmock;
|
|
31
33
|
__webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id)=>{
|
|
32
34
|
if (hasOwn(__webpack_require__.rstest_original_modules, id)) return __webpack_require__.rstest_original_modules[id];
|
|
33
35
|
if (hasOwn(__webpack_require__.rstest_original_module_factories, id)) {
|
package/dist/worker.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ declare type BrowserViewport = {
|
|
|
83
83
|
height: number;
|
|
84
84
|
} | DevicePreset;
|
|
85
85
|
|
|
86
|
-
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'blob';
|
|
86
|
+
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'json' | 'blob';
|
|
87
87
|
|
|
88
88
|
declare type BuiltinReporterOptions = {
|
|
89
89
|
default: DefaultReporterOptions;
|
|
@@ -91,6 +91,7 @@ declare type BuiltinReporterOptions = {
|
|
|
91
91
|
md: MdReporterOptions;
|
|
92
92
|
'github-actions': Record<string, unknown>;
|
|
93
93
|
junit: Record<string, unknown>;
|
|
94
|
+
json: JsonReporterOptions;
|
|
94
95
|
blob: BlobReporterOptions;
|
|
95
96
|
};
|
|
96
97
|
|
|
@@ -220,11 +221,14 @@ declare type CoverageOptions = {
|
|
|
220
221
|
* This option accepts an array of wax(https://crates.io/crates/wax)-compatible glob patterns
|
|
221
222
|
*
|
|
222
223
|
* @default ['**\/node_modules/**',
|
|
223
|
-
* '**\/dist/**',
|
|
224
224
|
* '**\/test/**',
|
|
225
225
|
* '**\/__tests__/**',
|
|
226
|
-
* '
|
|
227
|
-
* '
|
|
226
|
+
* '**\/__mocks__/**',
|
|
227
|
+
* '**\/*.d.ts',
|
|
228
|
+
* '**\/*.{test,spec}.[jt]s',
|
|
229
|
+
* '**\/*.{test,spec}.[cm][jt]s',
|
|
230
|
+
* '**\/*.{test,spec}.[jt]sx',
|
|
231
|
+
* '**\/*.{test,spec}.[cm][jt]sx'
|
|
228
232
|
* ]
|
|
229
233
|
*/
|
|
230
234
|
exclude?: string[];
|
|
@@ -449,6 +453,13 @@ declare type InlineProjectConfig = ProjectConfig & {
|
|
|
449
453
|
|
|
450
454
|
declare type JsonOptions = FileOptions;
|
|
451
455
|
|
|
456
|
+
declare type JsonReporterOptions = {
|
|
457
|
+
/**
|
|
458
|
+
* Write report JSON to a file instead of stdout.
|
|
459
|
+
*/
|
|
460
|
+
outputPath?: string;
|
|
461
|
+
};
|
|
462
|
+
|
|
452
463
|
declare type JsonSummaryOptions = FileOptions;
|
|
453
464
|
|
|
454
465
|
declare interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
|
|
@@ -592,7 +603,7 @@ declare type NormalizedBrowserModeConfig = {
|
|
|
592
603
|
providerOptions: Record<string, unknown>;
|
|
593
604
|
};
|
|
594
605
|
|
|
595
|
-
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
606
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser' | 'output'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
596
607
|
pool: RstestPoolOptions;
|
|
597
608
|
testEnvironment: EnvironmentWithOptions;
|
|
598
609
|
coverage: NormalizedCoverageOptions;
|
|
@@ -603,6 +614,7 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
|
|
|
603
614
|
patterns: string[];
|
|
604
615
|
override?: boolean;
|
|
605
616
|
};
|
|
617
|
+
output: NormalizedOutputConfig;
|
|
606
618
|
};
|
|
607
619
|
|
|
608
620
|
declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresholds' | 'include'>> & {
|
|
@@ -610,9 +622,16 @@ declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresho
|
|
|
610
622
|
include?: string[];
|
|
611
623
|
};
|
|
612
624
|
|
|
613
|
-
declare type
|
|
625
|
+
declare type NormalizedOutputConfig = Partial<Omit<RstestOutputConfig, 'distPath'>> & {
|
|
626
|
+
distPath: {
|
|
627
|
+
root: string;
|
|
628
|
+
};
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup' | 'output'>> & Pick<NormalizedConfig, OptionalKeys> & {
|
|
614
632
|
setupFiles: string[];
|
|
615
633
|
globalSetup: string[];
|
|
634
|
+
output?: Omit<NormalizedOutputConfig, 'distPath'>;
|
|
616
635
|
};
|
|
617
636
|
|
|
618
637
|
declare interface OldPlugin {
|
|
@@ -620,7 +639,7 @@ declare interface OldPlugin {
|
|
|
620
639
|
test: Test;
|
|
621
640
|
}
|
|
622
641
|
|
|
623
|
-
declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | '
|
|
642
|
+
declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
|
|
624
643
|
|
|
625
644
|
declare interface Options {
|
|
626
645
|
logger: {
|
|
@@ -670,7 +689,9 @@ declare type Print = (arg0: unknown) => string;
|
|
|
670
689
|
|
|
671
690
|
declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
|
|
672
691
|
|
|
673
|
-
declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard'
|
|
692
|
+
declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'bail' | 'shard' | 'output'> & {
|
|
693
|
+
output?: Omit<RstestOutputConfig, 'distPath'>;
|
|
694
|
+
};
|
|
674
695
|
|
|
675
696
|
declare type ProjectContext = {
|
|
676
697
|
name: string;
|
|
@@ -1015,9 +1036,9 @@ declare interface RstestConfig {
|
|
|
1015
1036
|
*/
|
|
1016
1037
|
includeTaskLocation?: boolean;
|
|
1017
1038
|
plugins?: RsbuildConfig['plugins'];
|
|
1018
|
-
source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
|
|
1039
|
+
source?: Pick<NonNullable<RsbuildConfig['source']>, 'assetsInclude' | 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude' | 'transformImport' | 'assetsInclude'>;
|
|
1019
1040
|
dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
|
|
1020
|
-
output?:
|
|
1041
|
+
output?: RstestOutputConfig;
|
|
1021
1042
|
resolve?: RsbuildConfig['resolve'];
|
|
1022
1043
|
tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
|
|
1023
1044
|
}
|
|
@@ -1060,6 +1081,22 @@ declare type RstestContext = {
|
|
|
1060
1081
|
};
|
|
1061
1082
|
};
|
|
1062
1083
|
|
|
1084
|
+
declare type RstestOutputConfig = Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'> & {
|
|
1085
|
+
distPath?: string | {
|
|
1086
|
+
root?: string;
|
|
1087
|
+
};
|
|
1088
|
+
/**
|
|
1089
|
+
* Whether to bundle third-party dependencies from node_modules.
|
|
1090
|
+
* - `true`: Always bundle all third-party dependencies.
|
|
1091
|
+
* - `false`: Always externalize third-party dependencies.
|
|
1092
|
+
*
|
|
1093
|
+
* When unset, rstest bundles dependencies in browser-like test
|
|
1094
|
+
* environments (jsdom, happy-dom, etc.) and externalizes them in the node
|
|
1095
|
+
* environment. This option is not supported in browser mode.
|
|
1096
|
+
*/
|
|
1097
|
+
bundleDependencies?: boolean;
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1063
1100
|
declare type RstestPoolOptions = {
|
|
1064
1101
|
/** Pool used to run tests in. */
|
|
1065
1102
|
type?: RstestPoolType;
|
package/dist/worker.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
|
+
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
3
3
|
import { existsSync, promises } from "node:fs";
|
|
4
4
|
import "./1255.js";
|
|
5
5
|
import { createWorkerMetaMessage, createBirpc } from "./1983.js";
|
|
6
|
-
import { basename, isAbsolute, color as logger_color, dirname, resolve as pathe_M_eThtNZ_resolve, join } from "./6830.js";
|
|
7
|
-
import { createCoverageProvider } from "./7704.js";
|
|
6
|
+
import { basename, isAbsolute, color as logger_color, dirname, globalApis, resolve as pathe_M_eThtNZ_resolve, join } from "./6830.js";
|
|
8
7
|
import { formatTestError, setRealTimers, getRealTimers } from "./7552.js";
|
|
9
|
-
import { globalApis } from "./4411.js";
|
|
10
8
|
const processSend = process.send.bind(process);
|
|
11
9
|
const processOn = process.on.bind(process);
|
|
12
10
|
const processOff = process.off.bind(process);
|
|
@@ -122,7 +120,7 @@ const setErrorName = (error, type)=>{
|
|
|
122
120
|
};
|
|
123
121
|
const setupEnv = (env)=>{
|
|
124
122
|
if (env) Object.entries(env).forEach(([key, value])=>{
|
|
125
|
-
if (void 0 === value)
|
|
123
|
+
if (void 0 === value) Reflect.deleteProperty(process.env, key);
|
|
126
124
|
else process.env[key] = value;
|
|
127
125
|
});
|
|
128
126
|
};
|
|
@@ -308,14 +306,14 @@ const runInPool = async (options)=>{
|
|
|
308
306
|
project,
|
|
309
307
|
testPath,
|
|
310
308
|
tests,
|
|
311
|
-
errors: formatTestError(unhandledErrors)
|
|
309
|
+
errors: await formatTestError(unhandledErrors)
|
|
312
310
|
};
|
|
313
311
|
} catch (err) {
|
|
314
312
|
return {
|
|
315
313
|
project,
|
|
316
314
|
testPath,
|
|
317
315
|
tests: [],
|
|
318
|
-
errors: formatTestError(err)
|
|
316
|
+
errors: await formatTestError(err)
|
|
319
317
|
};
|
|
320
318
|
} finally{
|
|
321
319
|
await teardown();
|
|
@@ -330,7 +328,11 @@ const runInPool = async (options)=>{
|
|
|
330
328
|
name: '',
|
|
331
329
|
results: []
|
|
332
330
|
};
|
|
333
|
-
|
|
331
|
+
let coverageProvider = null;
|
|
332
|
+
if (options.context.runtimeConfig.coverage?.enabled) {
|
|
333
|
+
const { createCoverageProvider } = await import("./7704.js");
|
|
334
|
+
coverageProvider = await createCoverageProvider(options.context.runtimeConfig.coverage, options.context.rootPath);
|
|
335
|
+
}
|
|
334
336
|
if (coverageProvider) coverageProvider.init();
|
|
335
337
|
const { assetFiles, sourceMaps: sourceMapsFromAssets } = assets || await rpc.getAssetsByEntry();
|
|
336
338
|
sourceMaps = sourceMapsFromAssets;
|
|
@@ -369,7 +371,7 @@ const runInPool = async (options)=>{
|
|
|
369
371
|
}, api);
|
|
370
372
|
if (unhandledErrors.length > 0) {
|
|
371
373
|
results.status = 'fail';
|
|
372
|
-
results.errors = (results.errors || []).concat(...formatTestError(unhandledErrors));
|
|
374
|
+
results.errors = (results.errors || []).concat(...await formatTestError(unhandledErrors));
|
|
373
375
|
}
|
|
374
376
|
if (coverageProvider) {
|
|
375
377
|
const coverageMap = coverageProvider.collect();
|
|
@@ -391,7 +393,7 @@ const runInPool = async (options)=>{
|
|
|
391
393
|
status: 'fail',
|
|
392
394
|
name: '',
|
|
393
395
|
results: [],
|
|
394
|
-
errors: formatTestError(err)
|
|
396
|
+
errors: await formatTestError(err)
|
|
395
397
|
};
|
|
396
398
|
} finally{
|
|
397
399
|
await teardown();
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rstest",
|
|
7
|
+
"test",
|
|
8
|
+
"rstack",
|
|
9
|
+
"rspack"
|
|
10
|
+
],
|
|
5
11
|
"bugs": {
|
|
6
12
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
7
13
|
},
|
|
@@ -10,19 +16,8 @@
|
|
|
10
16
|
"url": "https://github.com/web-infra-dev/rstest",
|
|
11
17
|
"directory": "packages/core"
|
|
12
18
|
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"rstest",
|
|
15
|
-
"test",
|
|
16
|
-
"rstack",
|
|
17
|
-
"rspack"
|
|
18
|
-
],
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"type": "module",
|
|
21
|
-
"main": "./dist/index.js",
|
|
22
|
-
"types": "./dist/index.d.ts",
|
|
23
|
-
"bin": {
|
|
24
|
-
"rstest": "./bin/rstest.js"
|
|
25
|
-
},
|
|
26
21
|
"exports": {
|
|
27
22
|
".": {
|
|
28
23
|
"types": "./dist/index.d.ts",
|
|
@@ -46,6 +41,11 @@
|
|
|
46
41
|
"types": "./importMeta.d.ts"
|
|
47
42
|
}
|
|
48
43
|
},
|
|
44
|
+
"main": "./dist/index.js",
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"bin": {
|
|
47
|
+
"rstest": "./bin/rstest.js"
|
|
48
|
+
},
|
|
49
49
|
"files": [
|
|
50
50
|
"bin",
|
|
51
51
|
"dist",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
"importMeta.d.ts"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@rsbuild/core": "2.0.0-
|
|
57
|
+
"@rsbuild/core": "2.0.0-rc.0",
|
|
58
58
|
"@types/chai": "^5.2.3",
|
|
59
59
|
"tinypool": "^2.1.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@babel/code-frame": "^7.29.0",
|
|
63
|
-
"@clack/prompts": "^1.
|
|
63
|
+
"@clack/prompts": "^1.2.0",
|
|
64
64
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
65
|
-
"@microsoft/api-extractor": "^7.57.
|
|
65
|
+
"@microsoft/api-extractor": "^7.57.8",
|
|
66
66
|
"@rsbuild/plugin-less": "^1.6.2",
|
|
67
67
|
"@rsbuild/plugin-node-polyfill": "^1.4.4",
|
|
68
68
|
"@rsbuild/plugin-sass": "^1.5.1",
|
|
69
|
-
"@rslib/core": "0.20.
|
|
70
|
-
"@sinonjs/fake-timers": "^15.
|
|
69
|
+
"@rslib/core": "0.20.2",
|
|
70
|
+
"@sinonjs/fake-timers": "^15.2.0",
|
|
71
71
|
"@types/babel__code-frame": "^7.27.0",
|
|
72
72
|
"@types/istanbul-lib-coverage": "^2.0.6",
|
|
73
73
|
"@types/istanbul-lib-report": "^3.0.3",
|
|
@@ -76,23 +76,23 @@
|
|
|
76
76
|
"@types/picomatch": "^4.0.2",
|
|
77
77
|
"@types/sinonjs__fake-timers": "^8.1.5",
|
|
78
78
|
"@types/source-map-support": "^0.5.10",
|
|
79
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
79
|
+
"@typescript/native-preview": "7.0.0-dev.20260331.1",
|
|
80
80
|
"@vitest/expect": "^3.2.4",
|
|
81
|
+
"@vitest/pretty-format": "^3.2.4",
|
|
81
82
|
"@vitest/snapshot": "^3.2.4",
|
|
83
|
+
"@vitest/utils": "^3.2.4",
|
|
82
84
|
"birpc": "^4.0.0",
|
|
83
85
|
"cac": "^7.0.0",
|
|
84
86
|
"chai": "^6.2.2",
|
|
85
87
|
"chokidar": "^5.0.0",
|
|
86
|
-
"happy-dom": "^20.8.
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"memfs": "^4.56.11",
|
|
88
|
+
"happy-dom": "^20.8.9",
|
|
89
|
+
"jsdom": "^29.0.1",
|
|
90
|
+
"memfs": "^4.57.1",
|
|
90
91
|
"package-manager-detector": "^1.6.0",
|
|
91
92
|
"pathe": "^2.0.3",
|
|
92
93
|
"picocolors": "^1.1.1",
|
|
93
|
-
"picomatch": "^4.0.
|
|
94
|
-
"
|
|
95
|
-
"rslog": "^2.0.1",
|
|
94
|
+
"picomatch": "^4.0.4",
|
|
95
|
+
"rslog": "^2.1.1",
|
|
96
96
|
"source-map-support": "^0.5.21",
|
|
97
97
|
"stacktrace-parser": "0.1.11",
|
|
98
98
|
"std-env": "^4.0.0",
|
|
@@ -102,7 +102,6 @@
|
|
|
102
102
|
"url-extras": "^0.1.0",
|
|
103
103
|
"webpack": "^5.105.4",
|
|
104
104
|
"webpack-license-plugin": "^4.5.1",
|
|
105
|
-
"@rstest/browser-ui": "0.0.0",
|
|
106
105
|
"@rstest/tsconfig": "0.0.1"
|
|
107
106
|
},
|
|
108
107
|
"peerDependencies": {
|
|
@@ -126,8 +125,8 @@
|
|
|
126
125
|
},
|
|
127
126
|
"scripts": {
|
|
128
127
|
"build": "rslib build && npx prettier ./LICENSE.md --write",
|
|
129
|
-
"typecheck": "tsc --noEmit",
|
|
130
128
|
"dev": "cross-env SOURCEMAP=true rslib build --watch",
|
|
131
|
-
"test": "npx rstest --globals"
|
|
129
|
+
"test": "npx rstest --globals",
|
|
130
|
+
"typecheck": "pnpm -w exec tsc --noEmit -p packages/core/tsconfig.json"
|
|
132
131
|
}
|
|
133
132
|
}
|