@rstest/core 0.9.0 → 0.9.1
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 +2 -2
- package/dist/0~130.js +0 -1
- package/dist/0~1472.js +1 -1
- package/dist/0~2173.js +20 -3
- package/dist/0~5835.js +18 -5
- package/dist/0~6588.js +1 -1
- package/dist/0~6923.js +11 -3
- package/dist/0~7583.js +3 -3
- package/dist/0~7882.js +18 -18
- package/dist/0~89.js +31 -11
- package/dist/0~9634.js +1 -1
- package/dist/0~9744.js +1014 -0
- package/dist/1157.js +1 -1
- package/dist/1294.js +1 -1
- package/dist/3160.js +16 -21
- package/dist/487.js +1 -1
- package/dist/6151.js +3013 -22
- package/dist/9131.js +154 -91
- package/dist/browser-runtime/389.js +3022 -38
- package/dist/index.d.ts +3 -0
- package/dist/mockRuntimeCode.js +15 -9
- package/dist/worker.js +4 -1
- package/package.json +7 -5
- package/dist/0~1240.js +0 -951
- package/dist/0~1981.js +0 -2
- package/dist/721.js +0 -8
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { config } from 'chai';
|
|
|
3
3
|
import { LoadConfigOptions } from '@rsbuild/core';
|
|
4
4
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
5
5
|
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
6
|
+
import { Rspack } from '@rsbuild/core';
|
|
6
7
|
import type { Writable } from 'node:stream';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -2511,6 +2512,8 @@ export declare const rs: RstestUtilities;
|
|
|
2511
2512
|
|
|
2512
2513
|
export { RsbuildPlugin }
|
|
2513
2514
|
|
|
2515
|
+
export { Rspack }
|
|
2516
|
+
|
|
2514
2517
|
export declare type Rstest = RunnerAPI & {
|
|
2515
2518
|
expect: Expect;
|
|
2516
2519
|
assert: typeof assert_2;
|
package/dist/mockRuntimeCode.js
CHANGED
|
@@ -20,6 +20,8 @@ __webpack_require__ = new Proxy(function(...args) {
|
|
|
20
20
|
});
|
|
21
21
|
__webpack_require__.rstest_original_modules = {};
|
|
22
22
|
__webpack_require__.rstest_original_module_factories = {};
|
|
23
|
+
const hasOwn = (target, property)=>Object.hasOwn(target, property);
|
|
24
|
+
const isPromise = (value)=>value instanceof Promise;
|
|
23
25
|
__webpack_require__.rstest_unmock = (id)=>{
|
|
24
26
|
const originalModuleFactory = __webpack_require__.rstest_original_module_factories[id];
|
|
25
27
|
if (originalModuleFactory) __webpack_modules__[id] = originalModuleFactory;
|
|
@@ -27,9 +29,8 @@ __webpack_require__.rstest_unmock = (id)=>{
|
|
|
27
29
|
};
|
|
28
30
|
__webpack_require__.rstest_do_unmock = __webpack_require__.rstest_unmock;
|
|
29
31
|
__webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id)=>{
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
if (id in __webpack_require__.rstest_original_module_factories) {
|
|
32
|
+
if (hasOwn(__webpack_require__.rstest_original_modules, id)) return __webpack_require__.rstest_original_modules[id];
|
|
33
|
+
if (hasOwn(__webpack_require__.rstest_original_module_factories, id)) {
|
|
33
34
|
const mod = __webpack_require__.rstest_original_module_factories[id];
|
|
34
35
|
const moduleInstance = {
|
|
35
36
|
exports: {}
|
|
@@ -43,12 +44,13 @@ __webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_ac
|
|
|
43
44
|
const getMockImplementation = (mockType = 'mock')=>{
|
|
44
45
|
const isMockRequire = 'mockRequire' === mockType || 'doMockRequire' === mockType;
|
|
45
46
|
return (id, modFactory)=>{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const hasCachedModule = hasOwn(__webpack_module_cache__, id);
|
|
48
|
+
let requiredModule = hasCachedModule ? __webpack_module_cache__[id].exports : void 0;
|
|
49
|
+
const wasAlreadyLoaded = hasCachedModule;
|
|
50
|
+
const hasSavedOriginalModule = hasOwn(__webpack_require__.rstest_original_modules, id);
|
|
51
|
+
const hasSavedOriginalFactory = hasOwn(__webpack_require__.rstest_original_module_factories, id);
|
|
52
|
+
if (!hasSavedOriginalModule && hasCachedModule) __webpack_require__.rstest_original_modules[id] = requiredModule;
|
|
53
|
+
if (!hasSavedOriginalFactory) __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
|
|
52
54
|
if (modFactory && 'object' == typeof modFactory) {
|
|
53
55
|
const isSpy = true === modFactory.spy;
|
|
54
56
|
const isMock = true === modFactory.mock;
|
|
@@ -91,6 +93,10 @@ const getMockImplementation = (mockType = 'mock')=>{
|
|
|
91
93
|
else if ('function' == typeof modFactory) {
|
|
92
94
|
const finalModFactory = function(__webpack_module__, __webpack_exports__, __webpack_require__1) {
|
|
93
95
|
const res = modFactory();
|
|
96
|
+
if (isPromise(res)) {
|
|
97
|
+
__webpack_module__.exports = res;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
94
100
|
if (isMockRequire) {
|
|
95
101
|
__webpack_module__.exports = res;
|
|
96
102
|
return;
|
package/dist/worker.js
CHANGED
|
@@ -102,7 +102,10 @@ const registerGlobalApi = (api)=>globalApis.reduce((apis, key)=>{
|
|
|
102
102
|
const globalCleanups = [];
|
|
103
103
|
let isTeardown = false;
|
|
104
104
|
const setupEnv = (env)=>{
|
|
105
|
-
if (env) Object.
|
|
105
|
+
if (env) Object.entries(env).forEach(([key, value])=>{
|
|
106
|
+
if (void 0 === value) delete process.env[key];
|
|
107
|
+
else process.env[key] = value;
|
|
108
|
+
});
|
|
106
109
|
};
|
|
107
110
|
const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot, context })=>{
|
|
108
111
|
globalCleanups.forEach((fn)=>{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -59,8 +59,10 @@
|
|
|
59
59
|
"tinypool": "^2.1.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
+
"@rsbuild/plugin-less": "^1.6.0",
|
|
63
|
+
"@rsbuild/plugin-sass": "^1.5.0",
|
|
62
64
|
"@babel/code-frame": "^7.29.0",
|
|
63
|
-
"@clack/prompts": "^
|
|
65
|
+
"@clack/prompts": "^1.1.0",
|
|
64
66
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
65
67
|
"@microsoft/api-extractor": "^7.57.6",
|
|
66
68
|
"@rsbuild/plugin-node-polyfill": "^1.4.4",
|
|
@@ -77,8 +79,8 @@
|
|
|
77
79
|
"@vitest/expect": "^3.2.4",
|
|
78
80
|
"@vitest/snapshot": "^3.2.4",
|
|
79
81
|
"birpc": "^4.0.0",
|
|
80
|
-
"cac": "^
|
|
81
|
-
"chai": "^
|
|
82
|
+
"cac": "^7.0.0",
|
|
83
|
+
"chai": "^6.2.2",
|
|
82
84
|
"chokidar": "^4.0.3",
|
|
83
85
|
"happy-dom": "^20.7.0",
|
|
84
86
|
"jest-diff": "^30.2.0",
|
|
@@ -89,7 +91,7 @@
|
|
|
89
91
|
"picocolors": "^1.1.1",
|
|
90
92
|
"picomatch": "^4.0.3",
|
|
91
93
|
"pretty-format": "^30.2.0",
|
|
92
|
-
"rslog": "^
|
|
94
|
+
"rslog": "^2.0.0",
|
|
93
95
|
"source-map-support": "^0.5.21",
|
|
94
96
|
"stacktrace-parser": "0.1.11",
|
|
95
97
|
"std-env": "^3.10.0",
|