@rstest/core 0.7.7 → 0.7.8
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~4809.js +3 -3
- package/dist/0~6151.js +0 -8
- package/dist/0~62.js +2 -2
- package/dist/0~89.js +9 -3
- package/dist/1157.js +1 -1
- package/dist/554.js +4 -4
- package/dist/9131.js +9 -4
- package/dist/cssFilterLoader.mjs +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/worker.d.ts +10 -2
- package/package.json +3 -3
package/dist/0~4809.js
CHANGED
|
@@ -4,12 +4,12 @@ import { checkPkgInstalled } from "./7913.js";
|
|
|
4
4
|
import { installGlobal, addDefaultErrorHandler } from "./0~3062.js";
|
|
5
5
|
const environment = {
|
|
6
6
|
name: 'happy-dom',
|
|
7
|
-
async
|
|
7
|
+
setup: async (global, options = {})=>{
|
|
8
8
|
checkPkgInstalled('happy-dom');
|
|
9
9
|
const { Window } = await import("happy-dom");
|
|
10
10
|
const win = new Window({
|
|
11
|
-
...
|
|
12
|
-
url:
|
|
11
|
+
...options,
|
|
12
|
+
url: options.url || 'http://localhost:3000',
|
|
13
13
|
console: console && global.console ? global.console : void 0
|
|
14
14
|
});
|
|
15
15
|
const cleanupGlobal = installGlobal(global, win, {
|
package/dist/0~6151.js
CHANGED
|
@@ -11774,10 +11774,6 @@ const SnapshotPlugin = (workerState)=>{
|
|
|
11774
11774
|
const isNot = utils.flag(this, 'negate');
|
|
11775
11775
|
if (isNot) throw new Error('toMatchInlineSnapshot cannot be used with "not"');
|
|
11776
11776
|
const test = getTest(this);
|
|
11777
|
-
if (test) {
|
|
11778
|
-
const isInsideEach = test.each || test.inTestEach;
|
|
11779
|
-
if (isInsideEach) throw new Error('InlineSnapshot cannot be used inside of test.each or describe.each');
|
|
11780
|
-
}
|
|
11781
11777
|
const expected = utils.flag(this, 'object');
|
|
11782
11778
|
const error = utils.flag(this, 'error');
|
|
11783
11779
|
if ('string' == typeof properties) {
|
|
@@ -11821,10 +11817,6 @@ const SnapshotPlugin = (workerState)=>{
|
|
|
11821
11817
|
const isNot = utils.flag(this, 'negate');
|
|
11822
11818
|
if (isNot) throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
|
|
11823
11819
|
const test = getTest(this);
|
|
11824
|
-
if (test) {
|
|
11825
|
-
const isInsideEach = test.each || test.inTestEach;
|
|
11826
|
-
if (isInsideEach) throw new Error('InlineSnapshot cannot be used inside of test.each or describe.each');
|
|
11827
|
-
}
|
|
11828
11820
|
const expected = utils.flag(this, 'object');
|
|
11829
11821
|
const error = utils.flag(this, 'error');
|
|
11830
11822
|
const promise = utils.flag(this, 'promise');
|
package/dist/0~62.js
CHANGED
|
@@ -4,10 +4,10 @@ import { checkPkgInstalled } from "./7913.js";
|
|
|
4
4
|
import { installGlobal, addDefaultErrorHandler } from "./0~3062.js";
|
|
5
5
|
const environment = {
|
|
6
6
|
name: 'jsdom',
|
|
7
|
-
async
|
|
7
|
+
setup: async (global, options)=>{
|
|
8
8
|
checkPkgInstalled('jsdom');
|
|
9
9
|
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import("jsdom");
|
|
10
|
-
const { html = '<!DOCTYPE html>', userAgent, url = 'http://localhost:3000', contentType = 'text/html', pretendToBeVisual = true, includeNodeLocations = false, runScripts = 'dangerously', resources, console = false, cookieJar = false, ...restOptions } =
|
|
10
|
+
const { html = '<!DOCTYPE html>', userAgent, url = 'http://localhost:3000', contentType = 'text/html', pretendToBeVisual = true, includeNodeLocations = false, runScripts = 'dangerously', resources, console = false, cookieJar = false, ...restOptions } = options;
|
|
11
11
|
const dom = new JSDOM(html, {
|
|
12
12
|
pretendToBeVisual,
|
|
13
13
|
resources: resources ?? (userAgent ? new ResourceLoader({
|
package/dist/0~89.js
CHANGED
|
@@ -408,10 +408,11 @@ const require = /*#__PURE__*/ __rstest_shim_module__.createRequire(import.meta.u
|
|
|
408
408
|
const pluginBasic = (context)=>({
|
|
409
409
|
name: 'rstest:basic',
|
|
410
410
|
setup: (api)=>{
|
|
411
|
-
api.modifyBundlerChain((chain)=>{
|
|
411
|
+
api.modifyBundlerChain((chain, { CHAIN_ID })=>{
|
|
412
412
|
chain.optimization.splitChunks({
|
|
413
413
|
chunks: 'all'
|
|
414
414
|
});
|
|
415
|
+
chain.module.rule(CHAIN_ID.RULE.JS).delete('type');
|
|
415
416
|
});
|
|
416
417
|
api.modifyEnvironmentConfig(async (config, { mergeEnvironmentConfig, name })=>{
|
|
417
418
|
const { normalizedConfig: { resolve, source, output, tools, performance, dev, testEnvironment }, outputModule, rootPath } = context.projects.find((p)=>p.environmentName === name);
|
|
@@ -457,6 +458,11 @@ const pluginBasic = (context)=>({
|
|
|
457
458
|
hoistMockModule: true,
|
|
458
459
|
manualMockRoot: posix.resolve(rootPath, '__mocks__')
|
|
459
460
|
}));
|
|
461
|
+
config.module.rules ??= [];
|
|
462
|
+
config.module.rules.push({
|
|
463
|
+
test: /\.mts$/,
|
|
464
|
+
type: "javascript/esm"
|
|
465
|
+
});
|
|
460
466
|
if (outputModule) config.plugins.push(new rspack.BannerPlugin({
|
|
461
467
|
banner: requireShim,
|
|
462
468
|
stage: rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE - 1,
|
|
@@ -485,7 +491,7 @@ const pluginBasic = (context)=>({
|
|
|
485
491
|
'.jsx',
|
|
486
492
|
'.tsx'
|
|
487
493
|
];
|
|
488
|
-
if ('node' === testEnvironment) config.resolve.mainFields = config.resolve.mainFields?.filter((filed)=>'module' !== filed) || [
|
|
494
|
+
if ('node' === testEnvironment.name) config.resolve.mainFields = config.resolve.mainFields?.filter((filed)=>'module' !== filed) || [
|
|
489
495
|
'main'
|
|
490
496
|
];
|
|
491
497
|
config.resolve.byDependency ??= {};
|
|
@@ -618,7 +624,7 @@ const pluginExternal = (context)=>({
|
|
|
618
624
|
const { normalizedConfig: { testEnvironment }, outputModule } = context.projects.find((p)=>p.environmentName === name);
|
|
619
625
|
return mergeEnvironmentConfig(config, {
|
|
620
626
|
output: {
|
|
621
|
-
externals: 'node' === testEnvironment ? [
|
|
627
|
+
externals: 'node' === testEnvironment.name ? [
|
|
622
628
|
autoExternalNodeModules(outputModule)
|
|
623
629
|
] : void 0
|
|
624
630
|
},
|
package/dist/1157.js
CHANGED
|
@@ -2012,6 +2012,7 @@ var Builder = class {
|
|
|
2012
2012
|
return this;
|
|
2013
2013
|
}
|
|
2014
2014
|
};
|
|
2015
|
+
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
|
|
2015
2016
|
const isReadonlyArray = Array.isArray;
|
|
2016
2017
|
const isWin = "win32" === process.platform;
|
|
2017
2018
|
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
@@ -2384,5 +2385,4 @@ const formatTestPath = (root, testFilePath)=>{
|
|
|
2384
2385
|
if (posix.isAbsolute(testPath) && testPath.includes(root)) testPath = posix.relative(root, testPath);
|
|
2385
2386
|
return prettyTestPath(testPath);
|
|
2386
2387
|
};
|
|
2387
|
-
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
|
|
2388
2388
|
export { ADDITIONAL_NODE_BUILTINS, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, ROOT_SUITE_NAME, TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB, TS_CONFIG_FILE, bgColor, castArray, filterProjects, formatError, formatRootStr, formatTestEntryName, formatTestPath, getAbsolutePath, getTaskNameWithPrefix, getTestEntries, glob, globalApis, isDynamicPattern, isObject, isTTY, lstat, needFlagExperimentalDetectModule, prettyTestPath, prettyTime, promises_stat, readdir, realpath, serializableConfig, undoSerializableConfig, writeFile };
|
package/dist/554.js
CHANGED
|
@@ -201,7 +201,7 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot,
|
|
|
201
201
|
process.off('unhandledRejection', unhandledRejection);
|
|
202
202
|
});
|
|
203
203
|
const { api, runner } = await createRstestRuntime(workerState);
|
|
204
|
-
switch(testEnvironment){
|
|
204
|
+
switch(testEnvironment.name){
|
|
205
205
|
case 'node':
|
|
206
206
|
break;
|
|
207
207
|
case 'jsdom':
|
|
@@ -209,7 +209,7 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot,
|
|
|
209
209
|
const { environment } = await import("./0~62.js").then((mod)=>({
|
|
210
210
|
environment: mod.environment
|
|
211
211
|
}));
|
|
212
|
-
const { teardown } = await environment.setup(global, {});
|
|
212
|
+
const { teardown } = await environment.setup(global, testEnvironment.options || {});
|
|
213
213
|
cleanupFns.push(()=>teardown(global));
|
|
214
214
|
break;
|
|
215
215
|
}
|
|
@@ -218,12 +218,12 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot,
|
|
|
218
218
|
const { environment } = await import("./0~4809.js").then((mod)=>({
|
|
219
219
|
environment: mod.environment
|
|
220
220
|
}));
|
|
221
|
-
const { teardown } = await environment.setup(global, {});
|
|
221
|
+
const { teardown } = await environment.setup(global, testEnvironment.options || {});
|
|
222
222
|
cleanupFns.push(async ()=>teardown(global));
|
|
223
223
|
break;
|
|
224
224
|
}
|
|
225
225
|
default:
|
|
226
|
-
throw new Error(`Unknown test environment: ${testEnvironment}`);
|
|
226
|
+
throw new Error(`Unknown test environment: ${testEnvironment.name}`);
|
|
227
227
|
}
|
|
228
228
|
if (globals) registerGlobalApi(api);
|
|
229
229
|
const rstestContext = {
|
package/dist/9131.js
CHANGED
|
@@ -503,7 +503,7 @@ function prepareCli() {
|
|
|
503
503
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger_logger.log();
|
|
504
504
|
}
|
|
505
505
|
function showRstest() {
|
|
506
|
-
logger_logger.greet(" Rstest v0.7.
|
|
506
|
+
logger_logger.greet(" Rstest v0.7.8");
|
|
507
507
|
logger_logger.log('');
|
|
508
508
|
}
|
|
509
509
|
const applyCommonOptions = (cli)=>{
|
|
@@ -547,7 +547,7 @@ const runRest = async ({ options, filters, command })=>{
|
|
|
547
547
|
function setupCommands() {
|
|
548
548
|
const cli = dist('rstest');
|
|
549
549
|
cli.help();
|
|
550
|
-
cli.version("0.7.
|
|
550
|
+
cli.version("0.7.8");
|
|
551
551
|
applyCommonOptions(cli);
|
|
552
552
|
cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
553
553
|
showRstest();
|
|
@@ -692,7 +692,9 @@ const createDefaultConfig = ()=>({
|
|
|
692
692
|
update: false,
|
|
693
693
|
testTimeout: 5000,
|
|
694
694
|
hookTimeout: 10000,
|
|
695
|
-
testEnvironment:
|
|
695
|
+
testEnvironment: {
|
|
696
|
+
name: 'node'
|
|
697
|
+
},
|
|
696
698
|
retry: 0,
|
|
697
699
|
reporters: 'true' === process.env.GITHUB_ACTIONS ? [
|
|
698
700
|
'default',
|
|
@@ -752,6 +754,9 @@ const withDefaultConfig = (config)=>{
|
|
|
752
754
|
merged.pool = 'string' == typeof config.pool ? {
|
|
753
755
|
type: config.pool
|
|
754
756
|
} : merged.pool;
|
|
757
|
+
merged.testEnvironment = 'string' == typeof config.testEnvironment ? {
|
|
758
|
+
name: config.testEnvironment
|
|
759
|
+
} : merged.testEnvironment;
|
|
755
760
|
return {
|
|
756
761
|
...merged,
|
|
757
762
|
include: merged.include.map((p)=>formatRootStr(p, merged.root)),
|
|
@@ -2381,7 +2386,7 @@ class Rstest {
|
|
|
2381
2386
|
});
|
|
2382
2387
|
this.reporters = reporters;
|
|
2383
2388
|
this.snapshotManager = snapshotManager;
|
|
2384
|
-
this.version = "0.7.
|
|
2389
|
+
this.version = "0.7.8";
|
|
2385
2390
|
this.rootPath = rootPath;
|
|
2386
2391
|
this.originalConfig = userConfig;
|
|
2387
2392
|
this.normalizedConfig = rstestConfig;
|
package/dist/cssFilterLoader.mjs
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -779,6 +779,13 @@ declare interface EncodedSourceMap extends SourceMapV3 {
|
|
|
779
779
|
|
|
780
780
|
declare type EncodedSourceMapXInput = EncodedSourceMap & XInput;
|
|
781
781
|
|
|
782
|
+
declare type EnvironmentName = 'node' | 'jsdom' | 'happy-dom';
|
|
783
|
+
|
|
784
|
+
declare type EnvironmentWithOptions = {
|
|
785
|
+
name: EnvironmentName;
|
|
786
|
+
options?: Record<string, any>;
|
|
787
|
+
};
|
|
788
|
+
|
|
782
789
|
export declare type Expect = ExpectStatic;
|
|
783
790
|
|
|
784
791
|
export declare const expect: Rstest['expect'];
|
|
@@ -2032,8 +2039,9 @@ declare interface Node_2 {
|
|
|
2032
2039
|
visit(visitor: Visitor, state: any): void;
|
|
2033
2040
|
}
|
|
2034
2041
|
|
|
2035
|
-
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
2042
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
2036
2043
|
pool: RstestPoolOptions;
|
|
2044
|
+
testEnvironment: EnvironmentWithOptions;
|
|
2037
2045
|
coverage: NormalizedCoverageOptions;
|
|
2038
2046
|
setupFiles: string[];
|
|
2039
2047
|
globalSetup: string[];
|
|
@@ -2398,7 +2406,7 @@ export declare interface RstestConfig {
|
|
|
2398
2406
|
*
|
|
2399
2407
|
* @default 'node'
|
|
2400
2408
|
*/
|
|
2401
|
-
testEnvironment?:
|
|
2409
|
+
testEnvironment?: EnvironmentName | EnvironmentWithOptions;
|
|
2402
2410
|
/**
|
|
2403
2411
|
* Stop running tests after n failures.
|
|
2404
2412
|
* Set to 0 to run all tests regardless of failures.
|
package/dist/worker.d.ts
CHANGED
|
@@ -671,6 +671,13 @@ declare type EntryInfo = {
|
|
|
671
671
|
files?: string[];
|
|
672
672
|
};
|
|
673
673
|
|
|
674
|
+
declare type EnvironmentName = 'node' | 'jsdom' | 'happy-dom';
|
|
675
|
+
|
|
676
|
+
declare type EnvironmentWithOptions = {
|
|
677
|
+
name: EnvironmentName;
|
|
678
|
+
options?: Record<string, any>;
|
|
679
|
+
};
|
|
680
|
+
|
|
674
681
|
declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
|
|
675
682
|
|
|
676
683
|
declare interface ExpectPollOptions {
|
|
@@ -1675,8 +1682,9 @@ declare interface Node_2 {
|
|
|
1675
1682
|
visit(visitor: Visitor, state: any): void;
|
|
1676
1683
|
}
|
|
1677
1684
|
|
|
1678
|
-
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
1685
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
1679
1686
|
pool: RstestPoolOptions;
|
|
1687
|
+
testEnvironment: EnvironmentWithOptions;
|
|
1680
1688
|
coverage: NormalizedCoverageOptions;
|
|
1681
1689
|
setupFiles: string[];
|
|
1682
1690
|
globalSetup: string[];
|
|
@@ -2011,7 +2019,7 @@ declare interface RstestConfig {
|
|
|
2011
2019
|
*
|
|
2012
2020
|
* @default 'node'
|
|
2013
2021
|
*/
|
|
2014
|
-
testEnvironment?:
|
|
2022
|
+
testEnvironment?: EnvironmentName | EnvironmentWithOptions;
|
|
2015
2023
|
/**
|
|
2016
2024
|
* Stop running tests after n failures.
|
|
2017
2025
|
* Set to 0 to run all tests regardless of failures.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
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.7.
|
|
50
|
+
"@rsbuild/core": "1.7.1",
|
|
51
51
|
"tinypool": "^1.1.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@babel/code-frame": "^7.27.1",
|
|
60
60
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
61
61
|
"@microsoft/api-extractor": "^7.55.2",
|
|
62
|
-
"@rslib/core": "^0.
|
|
62
|
+
"@rslib/core": "^0.19.0",
|
|
63
63
|
"@sinonjs/fake-timers": "^15.1.0",
|
|
64
64
|
"@types/babel__code-frame": "^7.0.6",
|
|
65
65
|
"@types/istanbul-reports": "^3.0.4",
|