@rstest/core 0.3.2 → 0.3.4
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/263.js +10 -5
- package/dist/350.js +5 -3
- package/dist/711.js +5 -3
- package/dist/85.js +3 -1
- package/dist/985.js +2 -0
- package/dist/index.js +41 -4
- package/dist/worker.js +26 -6
- package/globals.d.ts +1 -0
- package/package.json +1 -1
package/dist/263.js
CHANGED
|
@@ -9,10 +9,11 @@ export const __webpack_modules__ = {
|
|
|
9
9
|
__webpack_require__.d(__webpack_exports__, {
|
|
10
10
|
createRstest: ()=>createRstest
|
|
11
11
|
});
|
|
12
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
12
13
|
var manager = __webpack_require__("../../node_modules/.pnpm/@vitest+snapshot@3.2.4/node_modules/@vitest/snapshot/dist/manager.js");
|
|
14
|
+
var external_pathe_ = __webpack_require__("pathe");
|
|
13
15
|
var external_std_env_ = __webpack_require__("std-env");
|
|
14
16
|
var src_config = __webpack_require__("./src/config.ts");
|
|
15
|
-
var external_pathe_ = __webpack_require__("pathe");
|
|
16
17
|
var stack_trace_parser_esm = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
|
|
17
18
|
var utils = __webpack_require__("./src/utils/index.ts");
|
|
18
19
|
var external_node_util_ = __webpack_require__("node:util");
|
|
@@ -518,7 +519,6 @@ export const __webpack_modules__ = {
|
|
|
518
519
|
for (const result of test.results)logCase(result, slowTestThreshold);
|
|
519
520
|
}
|
|
520
521
|
}
|
|
521
|
-
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
522
522
|
function formatEnvironmentName(name) {
|
|
523
523
|
return name.replace(/[^a-zA-Z0-9\-_$]/g, '_');
|
|
524
524
|
}
|
|
@@ -544,7 +544,7 @@ export const __webpack_modules__ = {
|
|
|
544
544
|
this.command = command;
|
|
545
545
|
this.fileFilters = fileFilters;
|
|
546
546
|
this.configFilePath = configFilePath;
|
|
547
|
-
const rootPath = userConfig.root ? (0,
|
|
547
|
+
const rootPath = userConfig.root ? (0, utils.FI)(cwd, userConfig.root) : cwd;
|
|
548
548
|
const rstestConfig = (0, src_config.wX)(userConfig);
|
|
549
549
|
const reporters = 'list' !== command ? createReporters(rstestConfig.reporters, {
|
|
550
550
|
rootPath,
|
|
@@ -555,13 +555,18 @@ export const __webpack_modules__ = {
|
|
|
555
555
|
});
|
|
556
556
|
this.reporters = reporters;
|
|
557
557
|
this.snapshotManager = snapshotManager;
|
|
558
|
-
this.version = "0.3.
|
|
558
|
+
this.version = "0.3.4";
|
|
559
559
|
this.rootPath = rootPath;
|
|
560
560
|
this.originalConfig = userConfig;
|
|
561
561
|
this.normalizedConfig = rstestConfig;
|
|
562
562
|
this.projects = projects.length ? projects.map((project)=>{
|
|
563
563
|
const config = (0, src_config.wX)(project.config);
|
|
564
564
|
config.isolate = rstestConfig.isolate;
|
|
565
|
+
config.source ??= {};
|
|
566
|
+
if (!config.source.tsconfigPath) {
|
|
567
|
+
const tsconfigPath = (0, external_pathe_.join)(config.root, utils.WB);
|
|
568
|
+
if ((0, external_node_fs_.existsSync)(tsconfigPath)) config.source.tsconfigPath = tsconfigPath;
|
|
569
|
+
}
|
|
565
570
|
return {
|
|
566
571
|
configFilePath: project.configFilePath,
|
|
567
572
|
rootPath: config.root,
|
|
@@ -602,7 +607,7 @@ export const __webpack_modules__ = {
|
|
|
602
607
|
junit: JUnitReporter
|
|
603
608
|
};
|
|
604
609
|
function createReporters(reporters, initOptions = {}) {
|
|
605
|
-
const result = (0,
|
|
610
|
+
const result = (0, utils.bg)(reporters).map((reporter)=>{
|
|
606
611
|
if ('string' == typeof reporter || Array.isArray(reporter)) {
|
|
607
612
|
const [name, options = {}] = 'string' == typeof reporter ? [
|
|
608
613
|
reporter,
|
package/dist/350.js
CHANGED
|
@@ -9,17 +9,19 @@ export const __webpack_modules__ = {
|
|
|
9
9
|
__webpack_require__.d(__webpack_exports__, {
|
|
10
10
|
environment: ()=>environment
|
|
11
11
|
});
|
|
12
|
-
var
|
|
12
|
+
var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/runtime/util.ts");
|
|
13
|
+
var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/runtime/worker/env/utils.ts");
|
|
13
14
|
const environment = {
|
|
14
15
|
name: 'happy-dom',
|
|
15
16
|
async setup (global, { happyDom = {} }) {
|
|
17
|
+
(0, _util__WEBPACK_IMPORTED_MODULE_0__.DW)('happy-dom');
|
|
16
18
|
const { Window } = await import("happy-dom");
|
|
17
19
|
const win = new Window({
|
|
18
20
|
...happyDom,
|
|
19
21
|
url: happyDom.url || 'http://localhost:3000',
|
|
20
22
|
console: console && global.console ? global.console : void 0
|
|
21
23
|
});
|
|
22
|
-
const cleanupGlobal = (0,
|
|
24
|
+
const cleanupGlobal = (0, _utils__WEBPACK_IMPORTED_MODULE_1__.p5)(global, win, {
|
|
23
25
|
additionalKeys: [
|
|
24
26
|
'Request',
|
|
25
27
|
'Response',
|
|
@@ -27,7 +29,7 @@ export const __webpack_modules__ = {
|
|
|
27
29
|
'fetch'
|
|
28
30
|
]
|
|
29
31
|
});
|
|
30
|
-
const cleanupHandler = (0,
|
|
32
|
+
const cleanupHandler = (0, _utils__WEBPACK_IMPORTED_MODULE_1__.d1)(global);
|
|
31
33
|
return {
|
|
32
34
|
async teardown () {
|
|
33
35
|
cleanupHandler();
|
package/dist/711.js
CHANGED
|
@@ -9,10 +9,12 @@ export const __webpack_modules__ = {
|
|
|
9
9
|
__webpack_require__.d(__webpack_exports__, {
|
|
10
10
|
environment: ()=>environment
|
|
11
11
|
});
|
|
12
|
-
var
|
|
12
|
+
var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/runtime/util.ts");
|
|
13
|
+
var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/runtime/worker/env/utils.ts");
|
|
13
14
|
const environment = {
|
|
14
15
|
name: 'jsdom',
|
|
15
16
|
async setup (global, { jsdom = {} }) {
|
|
17
|
+
(0, _util__WEBPACK_IMPORTED_MODULE_0__.DW)('jsdom');
|
|
16
18
|
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import("jsdom");
|
|
17
19
|
const { html = '<!DOCTYPE html>', userAgent, url = 'http://localhost:3000', contentType = 'text/html', pretendToBeVisual = true, includeNodeLocations = false, runScripts = 'dangerously', resources, console = false, cookieJar = false, ...restOptions } = jsdom;
|
|
18
20
|
const dom = new JSDOM(html, {
|
|
@@ -29,8 +31,8 @@ export const __webpack_modules__ = {
|
|
|
29
31
|
userAgent,
|
|
30
32
|
...restOptions
|
|
31
33
|
});
|
|
32
|
-
const cleanupGlobal = (0,
|
|
33
|
-
const cleanupHandler = (0,
|
|
34
|
+
const cleanupGlobal = (0, _utils__WEBPACK_IMPORTED_MODULE_1__.p5)(global, dom.window);
|
|
35
|
+
const cleanupHandler = (0, _utils__WEBPACK_IMPORTED_MODULE_1__.d1)(global);
|
|
34
36
|
return {
|
|
35
37
|
teardown () {
|
|
36
38
|
cleanupHandler();
|
package/dist/85.js
CHANGED
|
@@ -1806,7 +1806,7 @@ export const __webpack_modules__ = {
|
|
|
1806
1806
|
configurable: true
|
|
1807
1807
|
});
|
|
1808
1808
|
const rstest = createRstestUtilities(workerState);
|
|
1809
|
-
|
|
1809
|
+
const runtime = {
|
|
1810
1810
|
runner,
|
|
1811
1811
|
api: {
|
|
1812
1812
|
...runnerAPI,
|
|
@@ -1816,6 +1816,8 @@ export const __webpack_modules__ = {
|
|
|
1816
1816
|
rs: rstest
|
|
1817
1817
|
}
|
|
1818
1818
|
};
|
|
1819
|
+
globalThis.RSTEST_API = runtime.api;
|
|
1820
|
+
return runtime;
|
|
1819
1821
|
};
|
|
1820
1822
|
},
|
|
1821
1823
|
"./src/utils/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
package/dist/985.js
CHANGED
|
@@ -43,6 +43,7 @@ export const __webpack_modules__ = {
|
|
|
43
43
|
},
|
|
44
44
|
tools: {
|
|
45
45
|
rspack: (config, { isProd, rspack })=>{
|
|
46
|
+
config.context = rootPath;
|
|
46
47
|
config.mode = isProd ? 'production' : 'development';
|
|
47
48
|
config.output ??= {};
|
|
48
49
|
config.output.iife = false;
|
|
@@ -457,6 +458,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
457
458
|
const rsbuildInstance = await (0, core_.createRsbuild)({
|
|
458
459
|
callerName: 'rstest',
|
|
459
460
|
rsbuildConfig: {
|
|
461
|
+
root: context.rootPath,
|
|
460
462
|
server: {
|
|
461
463
|
printUrls: false,
|
|
462
464
|
strictPort: false,
|
package/dist/index.js
CHANGED
|
@@ -2712,7 +2712,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2712
2712
|
function setupCommands() {
|
|
2713
2713
|
const cli = dist('rstest');
|
|
2714
2714
|
cli.help();
|
|
2715
|
-
cli.version("0.3.
|
|
2715
|
+
cli.version("0.3.4");
|
|
2716
2716
|
applyCommonOptions(cli);
|
|
2717
2717
|
cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
2718
2718
|
(0, prepare.N)();
|
|
@@ -2785,7 +2785,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2785
2785
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
2786
2786
|
}
|
|
2787
2787
|
function showRstest() {
|
|
2788
|
-
_utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.greet(" Rstest v0.3.
|
|
2788
|
+
_utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.greet(" Rstest v0.3.4");
|
|
2789
2789
|
_utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.log('');
|
|
2790
2790
|
}
|
|
2791
2791
|
},
|
|
@@ -2886,6 +2886,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2886
2886
|
"./src/utils/constants.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2887
2887
|
__webpack_require__.d(__webpack_exports__, {
|
|
2888
2888
|
EJ: ()=>TEMP_RSTEST_OUTPUT_DIR_GLOB,
|
|
2889
|
+
WB: ()=>TS_CONFIG_FILE,
|
|
2889
2890
|
kv: ()=>DEFAULT_CONFIG_EXTENSIONS,
|
|
2890
2891
|
t: ()=>DEFAULT_CONFIG_NAME,
|
|
2891
2892
|
vO: ()=>TEST_DELIMITER,
|
|
@@ -2903,6 +2904,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2903
2904
|
'.cjs',
|
|
2904
2905
|
'.cts'
|
|
2905
2906
|
];
|
|
2907
|
+
const TS_CONFIG_FILE = 'tsconfig.json';
|
|
2906
2908
|
},
|
|
2907
2909
|
"./src/utils/helper.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2908
2910
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -3072,9 +3074,10 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3072
3074
|
FI: ()=>helper.FI,
|
|
3073
3075
|
kv: ()=>constants.kv,
|
|
3074
3076
|
yW: ()=>helper.yW,
|
|
3075
|
-
|
|
3077
|
+
WB: ()=>constants.WB,
|
|
3076
3078
|
_o: ()=>logger._o,
|
|
3077
3079
|
pr: ()=>getSetupFiles,
|
|
3080
|
+
EQ: ()=>prettyTestPath,
|
|
3078
3081
|
Kv: ()=>helper.Kv,
|
|
3079
3082
|
zz: ()=>filterProjects,
|
|
3080
3083
|
mT: ()=>logger.mT,
|
|
@@ -3863,8 +3866,42 @@ async function runCLI() {
|
|
|
3863
3866
|
}
|
|
3864
3867
|
}
|
|
3865
3868
|
var src_config = __webpack_require__("./src/config.ts");
|
|
3869
|
+
const check = (name)=>{
|
|
3870
|
+
if (!globalThis.RSTEST_API?.[name]) throw new Error(`Rstest API '${name}' is not registered yet, please make sure you are running in a rstest environment.`);
|
|
3871
|
+
};
|
|
3872
|
+
const wrapRstestAPI = (name)=>{
|
|
3873
|
+
const fn = (...args)=>{
|
|
3874
|
+
check(name);
|
|
3875
|
+
return globalThis.RSTEST_API[name].call(globalThis.RSTEST_API[name], ...args);
|
|
3876
|
+
};
|
|
3877
|
+
return new Proxy(fn, {
|
|
3878
|
+
get (_target, key, receiver) {
|
|
3879
|
+
check(name);
|
|
3880
|
+
return Reflect.get(globalThis.RSTEST_API?.[name] || {}, key, receiver);
|
|
3881
|
+
}
|
|
3882
|
+
});
|
|
3883
|
+
};
|
|
3884
|
+
const wrapRstestUtilitiesAPI = (name)=>new Proxy({}, {
|
|
3885
|
+
get (_target, key, receiver) {
|
|
3886
|
+
check(name);
|
|
3887
|
+
return Reflect.get(globalThis.RSTEST_API?.[name] || {}, key, receiver);
|
|
3888
|
+
}
|
|
3889
|
+
});
|
|
3890
|
+
const expect = wrapRstestAPI('expect');
|
|
3891
|
+
const assert = wrapRstestAPI('assert');
|
|
3892
|
+
const it = wrapRstestAPI('it');
|
|
3893
|
+
const test = wrapRstestAPI('test');
|
|
3894
|
+
const describe = wrapRstestAPI('describe');
|
|
3895
|
+
const beforeAll = wrapRstestAPI('beforeAll');
|
|
3896
|
+
const afterAll = wrapRstestAPI('afterAll');
|
|
3897
|
+
const beforeEach = wrapRstestAPI('beforeEach');
|
|
3898
|
+
const afterEach = wrapRstestAPI('afterEach');
|
|
3899
|
+
const rstest = wrapRstestUtilitiesAPI('rstest');
|
|
3900
|
+
const rs = wrapRstestUtilitiesAPI('rs');
|
|
3901
|
+
const onTestFinished = wrapRstestAPI('onTestFinished');
|
|
3902
|
+
const onTestFailed = wrapRstestAPI('onTestFailed');
|
|
3866
3903
|
function defineConfig(config) {
|
|
3867
3904
|
return config;
|
|
3868
3905
|
}
|
|
3869
3906
|
var __webpack_exports__mergeRstestConfig = src_config.ST;
|
|
3870
|
-
export { defineConfig, runCLI, __webpack_exports__mergeRstestConfig as mergeRstestConfig };
|
|
3907
|
+
export { afterAll, afterEach, assert, beforeAll, beforeEach, defineConfig, describe, expect, it, onTestFailed, onTestFinished, rs, rstest, runCLI, test, __webpack_exports__mergeRstestConfig as mergeRstestConfig };
|
package/dist/worker.js
CHANGED
|
@@ -4967,12 +4967,14 @@ var __webpack_modules__ = {
|
|
|
4967
4967
|
},
|
|
4968
4968
|
"./src/runtime/util.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
4969
4969
|
__webpack_require__.d(__webpack_exports__, {
|
|
4970
|
-
|
|
4970
|
+
DW: ()=>checkPkgInstalled,
|
|
4971
4971
|
nD: ()=>formatName,
|
|
4972
4972
|
o9: ()=>formatTestError,
|
|
4973
|
+
zH: ()=>setRealTimers,
|
|
4973
4974
|
si: ()=>TestRegisterError,
|
|
4974
4975
|
rZ: ()=>getRealTimers
|
|
4975
4976
|
});
|
|
4977
|
+
var external_node_module_ = __webpack_require__("node:module");
|
|
4976
4978
|
var external_node_util_ = __webpack_require__("node:util");
|
|
4977
4979
|
var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.5/node_modules/jest-diff/build/index.js");
|
|
4978
4980
|
build.DIFF_DELETE;
|
|
@@ -5038,6 +5040,22 @@ var __webpack_modules__ = {
|
|
|
5038
5040
|
}
|
|
5039
5041
|
class TestRegisterError extends Error {
|
|
5040
5042
|
}
|
|
5043
|
+
class RstestError extends Error {
|
|
5044
|
+
fullStack;
|
|
5045
|
+
}
|
|
5046
|
+
function checkPkgInstalled(name) {
|
|
5047
|
+
const require = (0, external_node_module_.createRequire)(import.meta.url);
|
|
5048
|
+
try {
|
|
5049
|
+
require.resolve(name);
|
|
5050
|
+
} catch (error) {
|
|
5051
|
+
if ('MODULE_NOT_FOUND' === error.code) {
|
|
5052
|
+
const error = new RstestError(`Missing dependency "${name}". Please install it first.`);
|
|
5053
|
+
error.fullStack = true;
|
|
5054
|
+
throw error;
|
|
5055
|
+
}
|
|
5056
|
+
throw error;
|
|
5057
|
+
}
|
|
5058
|
+
}
|
|
5041
5059
|
},
|
|
5042
5060
|
"./src/runtime/worker/setup.ts": function() {
|
|
5043
5061
|
const gracefulExit = process.execArgv.some((execArg)=>execArg.startsWith('--perf') || execArg.startsWith('--prof') || execArg.startsWith('--cpu-prof') || execArg.startsWith('--heap-prof') || execArg.startsWith('--diagnostic-dir'));
|
|
@@ -5064,7 +5082,9 @@ var __webpack_modules__ = {
|
|
|
5064
5082
|
'beforeEach',
|
|
5065
5083
|
'rstest',
|
|
5066
5084
|
'rs',
|
|
5067
|
-
'assert'
|
|
5085
|
+
'assert',
|
|
5086
|
+
'onTestFinished',
|
|
5087
|
+
'onTestFailed'
|
|
5068
5088
|
];
|
|
5069
5089
|
},
|
|
5070
5090
|
"./src/utils/helper.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -5806,8 +5826,8 @@ class RstestSnapshotEnvironment extends NodeSnapshotEnvironment {
|
|
|
5806
5826
|
return `// Rstest Snapshot v${this.getVersion()}`;
|
|
5807
5827
|
}
|
|
5808
5828
|
}
|
|
5809
|
-
const
|
|
5810
|
-
|
|
5829
|
+
const registerGlobalApi = (api)=>constants.TE.reduce((apis, key)=>{
|
|
5830
|
+
globalThis[key] = api[key];
|
|
5811
5831
|
return apis;
|
|
5812
5832
|
}, {});
|
|
5813
5833
|
const listeners = [];
|
|
@@ -5896,11 +5916,11 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5896
5916
|
default:
|
|
5897
5917
|
throw new Error(`Unknown test environment: ${testEnvironment}`);
|
|
5898
5918
|
}
|
|
5919
|
+
if (globals) registerGlobalApi(api);
|
|
5899
5920
|
const rstestContext = {
|
|
5900
5921
|
global,
|
|
5901
5922
|
console: global.console,
|
|
5902
|
-
Error
|
|
5903
|
-
...globals ? getGlobalApi(api) : {}
|
|
5923
|
+
Error
|
|
5904
5924
|
};
|
|
5905
5925
|
rstestContext.global['@rstest/core'] = api;
|
|
5906
5926
|
return {
|
package/globals.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ declare global {
|
|
|
10
10
|
const afterEach: typeof import('@rstest/core')['afterEach'];
|
|
11
11
|
const onTestFinished: typeof import('@rstest/core')['onTestFinished'];
|
|
12
12
|
const onTestFailed: typeof import('@rstest/core')['onTestFailed'];
|
|
13
|
+
const rs: typeof import('@rstest/core')['rs'];
|
|
13
14
|
const rstest: typeof import('@rstest/core')['rstest'];
|
|
14
15
|
}
|
|
15
16
|
export {};
|