@rstest/core 0.1.0 → 0.1.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 → LICENSE.md} +481 -141
- package/dist/208.js +8342 -0
- package/dist/208.js.LICENSE.txt +47 -0
- package/dist/285.js +3 -1
- package/dist/355.js +3 -1
- package/dist/{950.js → 359.js} +65 -7
- package/dist/44.js +2 -0
- package/dist/443.js +1210 -0
- package/dist/629.js +2 -0
- package/dist/64.js +3 -1
- package/dist/72.js +2 -0
- package/dist/723.js +2 -0
- package/dist/813.js +3 -1
- package/dist/{562.js → 854.js} +44 -4
- package/dist/867.js +58 -44
- package/dist/965.js +2 -0
- package/dist/cli.js +20 -19
- package/dist/node.js +2 -0
- package/dist/public.js +2 -0
- package/dist/worker.js +83 -36
- package/dist-types/node.d.ts +33 -2
- package/dist-types/public.d.ts +1359 -30
- package/dist-types/worker.d.ts +1351 -23
- package/package.json +7 -8
- package/dist/81.js +0 -1467
package/dist/worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! For license information please see worker.js.LICENSE.txt */
|
|
2
|
+
import __rslib_shim_module__ from 'module';
|
|
3
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
2
4
|
import node_process from "node:process";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE__vitest_expect_97b57ccd__ from "@vitest/expect";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE__vitest_snapshot_692a7094__ from "@vitest/snapshot";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_chai__ from "chai";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__ from "node:assert";
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__ from "node:console";
|
|
@@ -10,7 +10,6 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/
|
|
|
10
10
|
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
11
11
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
12
12
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
13
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_timers_7045d530__ from "node:timers";
|
|
14
13
|
import * as __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__ from "node:tty";
|
|
15
14
|
import * as __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__ from "node:util";
|
|
16
15
|
import * as __WEBPACK_EXTERNAL_MODULE_pathe__ from "pathe";
|
|
@@ -18,7 +17,6 @@ import { pathToFileURL } from "node:url";
|
|
|
18
17
|
import node_vm from "node:vm";
|
|
19
18
|
import node_v8 from "node:v8";
|
|
20
19
|
import { createBirpc } from "birpc";
|
|
21
|
-
import { NodeSnapshotEnvironment } from "@vitest/snapshot/environment";
|
|
22
20
|
var __webpack_modules__ = {
|
|
23
21
|
"../../node_modules/.pnpm/@jest+diff-sequences@30.0.1/node_modules/@jest/diff-sequences/build/index.js": function(module) {
|
|
24
22
|
/*!
|
|
@@ -4969,8 +4967,11 @@ var __webpack_modules__ = {
|
|
|
4969
4967
|
},
|
|
4970
4968
|
"./src/runtime/util.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
4971
4969
|
__webpack_require__.d(__webpack_exports__, {
|
|
4972
|
-
|
|
4973
|
-
|
|
4970
|
+
KY: ()=>formatName,
|
|
4971
|
+
BH: ()=>getRealTimers,
|
|
4972
|
+
CD: ()=>setRealTimers,
|
|
4973
|
+
Ni: ()=>TestRegisterError,
|
|
4974
|
+
ov: ()=>formatTestError
|
|
4974
4975
|
});
|
|
4975
4976
|
var external_node_util_ = __webpack_require__("node:util");
|
|
4976
4977
|
var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.5/node_modules/jest-diff/build/index.js");
|
|
@@ -4984,7 +4985,12 @@ var __webpack_modules__ = {
|
|
|
4984
4985
|
build.diffLinesUnified2;
|
|
4985
4986
|
build.diffStringsRaw;
|
|
4986
4987
|
build.diffStringsUnified;
|
|
4987
|
-
const
|
|
4988
|
+
const REAL_TIMERS = {};
|
|
4989
|
+
const setRealTimers = ()=>{
|
|
4990
|
+
REAL_TIMERS.setTimeout ??= globalThis.setTimeout;
|
|
4991
|
+
};
|
|
4992
|
+
const getRealTimers = ()=>REAL_TIMERS;
|
|
4993
|
+
const formatTestError = (err, test)=>{
|
|
4988
4994
|
const errors = Array.isArray(err) ? err : [
|
|
4989
4995
|
err
|
|
4990
4996
|
];
|
|
@@ -4995,6 +5001,7 @@ var __webpack_modules__ = {
|
|
|
4995
5001
|
name: error.name,
|
|
4996
5002
|
stack: error.stack
|
|
4997
5003
|
};
|
|
5004
|
+
if (error instanceof TestRegisterError && test?.type === 'case') errObj.message = `Can't nest describe or test inside a test. ${error.message} because it is nested within test '${test.name}'`;
|
|
4998
5005
|
if (error.showDiff || void 0 === error.showDiff && void 0 !== error.expected && void 0 !== error.actual) errObj.diff = diff(err.expected, err.actual);
|
|
4999
5006
|
for (const key of [
|
|
5000
5007
|
'actual',
|
|
@@ -5027,6 +5034,8 @@ var __webpack_modules__ = {
|
|
|
5027
5034
|
}
|
|
5028
5035
|
return result;
|
|
5029
5036
|
}
|
|
5037
|
+
class TestRegisterError extends Error {
|
|
5038
|
+
}
|
|
5030
5039
|
},
|
|
5031
5040
|
"./src/runtime/worker/setup.ts": function() {
|
|
5032
5041
|
const gracefulExit = process.execArgv.some((execArg)=>execArg.startsWith('--perf') || execArg.startsWith('--prof') || execArg.startsWith('--cpu-prof') || execArg.startsWith('--heap-prof') || execArg.startsWith('--diagnostic-dir'));
|
|
@@ -5399,12 +5408,6 @@ var __webpack_modules__ = {
|
|
|
5399
5408
|
"timers/promises": function(module) {
|
|
5400
5409
|
module.exports = require("timers/promises");
|
|
5401
5410
|
},
|
|
5402
|
-
"@vitest/expect": function(module) {
|
|
5403
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__vitest_expect_97b57ccd__;
|
|
5404
|
-
},
|
|
5405
|
-
"@vitest/snapshot": function(module) {
|
|
5406
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__vitest_snapshot_692a7094__;
|
|
5407
|
-
},
|
|
5408
5411
|
chai: function(module) {
|
|
5409
5412
|
module.exports = __WEBPACK_EXTERNAL_MODULE_chai__;
|
|
5410
5413
|
},
|
|
@@ -5414,7 +5417,7 @@ var __webpack_modules__ = {
|
|
|
5414
5417
|
"node:console": function(module) {
|
|
5415
5418
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__;
|
|
5416
5419
|
},
|
|
5417
|
-
|
|
5420
|
+
fs: function(module) {
|
|
5418
5421
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
5419
5422
|
},
|
|
5420
5423
|
"node:fs/promises": function(module) {
|
|
@@ -5429,9 +5432,6 @@ var __webpack_modules__ = {
|
|
|
5429
5432
|
"node:path": function(module) {
|
|
5430
5433
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
|
|
5431
5434
|
},
|
|
5432
|
-
"node:timers": function(module) {
|
|
5433
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_timers_7045d530__;
|
|
5434
|
-
},
|
|
5435
5435
|
"node:tty": function(module) {
|
|
5436
5436
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__;
|
|
5437
5437
|
},
|
|
@@ -5568,7 +5568,6 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
5568
5568
|
};
|
|
5569
5569
|
})();
|
|
5570
5570
|
__webpack_require__("./src/runtime/worker/setup.ts");
|
|
5571
|
-
var external_node_timers_ = __webpack_require__("node:timers");
|
|
5572
5571
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
5573
5572
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
5574
5573
|
var util = __webpack_require__("./src/runtime/util.ts");
|
|
@@ -5627,7 +5626,7 @@ const createRequire = (filename, distPath, rstestContext, assetFiles, interopDef
|
|
|
5627
5626
|
return (0, external_node_module_.createRequire)(distPath);
|
|
5628
5627
|
}
|
|
5629
5628
|
})();
|
|
5630
|
-
const
|
|
5629
|
+
const require = (id)=>{
|
|
5631
5630
|
const currentDirectory = external_pathe_["default"].dirname(distPath);
|
|
5632
5631
|
const joinedPath = isRelativePath(id) ? external_pathe_["default"].join(currentDirectory, id) : id;
|
|
5633
5632
|
const content = assetFiles[joinedPath];
|
|
@@ -5646,9 +5645,9 @@ const createRequire = (filename, distPath, rstestContext, assetFiles, interopDef
|
|
|
5646
5645
|
const resolved = _require.resolve(id);
|
|
5647
5646
|
return _require(resolved);
|
|
5648
5647
|
};
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
return
|
|
5648
|
+
require.resolve = _require.resolve;
|
|
5649
|
+
require.main = _require.main;
|
|
5650
|
+
return require;
|
|
5652
5651
|
};
|
|
5653
5652
|
const defineRstestDynamicImport = ({ testPath, interopDefault, returnModule = false })=>async (specifier, importAttributes)=>{
|
|
5654
5653
|
const resolvedPath = (0, external_node_path_.isAbsolute)(specifier) ? pathToFileURL(specifier) : await import.meta.resolve(specifier, pathToFileURL(testPath));
|
|
@@ -5763,6 +5762,42 @@ function createRuntimeRpc(options) {
|
|
|
5763
5762
|
rpc
|
|
5764
5763
|
};
|
|
5765
5764
|
}
|
|
5765
|
+
var external_node_fs_ = __webpack_require__("fs");
|
|
5766
|
+
class NodeSnapshotEnvironment {
|
|
5767
|
+
constructor(options = {}){
|
|
5768
|
+
this.options = options;
|
|
5769
|
+
}
|
|
5770
|
+
getVersion() {
|
|
5771
|
+
return "1";
|
|
5772
|
+
}
|
|
5773
|
+
getHeader() {
|
|
5774
|
+
return `// Snapshot v${this.getVersion()}`;
|
|
5775
|
+
}
|
|
5776
|
+
async resolveRawPath(testPath, rawPath) {
|
|
5777
|
+
return (0, external_pathe_.isAbsolute)(rawPath) ? rawPath : (0, external_pathe_.resolve)((0, external_pathe_.dirname)(testPath), rawPath);
|
|
5778
|
+
}
|
|
5779
|
+
async resolvePath(filepath) {
|
|
5780
|
+
return (0, external_pathe_.join)((0, external_pathe_.join)((0, external_pathe_.dirname)(filepath), this.options.snapshotsDirName ?? "__snapshots__"), `${(0, external_pathe_.basename)(filepath)}.snap`);
|
|
5781
|
+
}
|
|
5782
|
+
async prepareDirectory(dirPath) {
|
|
5783
|
+
await external_node_fs_.promises.mkdir(dirPath, {
|
|
5784
|
+
recursive: true
|
|
5785
|
+
});
|
|
5786
|
+
}
|
|
5787
|
+
async saveSnapshotFile(filepath, snapshot) {
|
|
5788
|
+
await external_node_fs_.promises.mkdir((0, external_pathe_.dirname)(filepath), {
|
|
5789
|
+
recursive: true
|
|
5790
|
+
});
|
|
5791
|
+
await external_node_fs_.promises.writeFile(filepath, snapshot, "utf-8");
|
|
5792
|
+
}
|
|
5793
|
+
async readSnapshotFile(filepath) {
|
|
5794
|
+
if (!(0, external_node_fs_.existsSync)(filepath)) return null;
|
|
5795
|
+
return external_node_fs_.promises.readFile(filepath, "utf-8");
|
|
5796
|
+
}
|
|
5797
|
+
async removeSnapshotFile(filepath) {
|
|
5798
|
+
if ((0, external_node_fs_.existsSync)(filepath)) await external_node_fs_.promises.unlink(filepath);
|
|
5799
|
+
}
|
|
5800
|
+
}
|
|
5766
5801
|
class RstestSnapshotEnvironment extends NodeSnapshotEnvironment {
|
|
5767
5802
|
getHeader() {
|
|
5768
5803
|
return `// Rstest Snapshot v${this.getVersion()}`;
|
|
@@ -5775,6 +5810,7 @@ const getGlobalApi = (api)=>constants.io.reduce((apis, key)=>{
|
|
|
5775
5810
|
const listeners = [];
|
|
5776
5811
|
let isTeardown = false;
|
|
5777
5812
|
const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, updateSnapshot, context })=>{
|
|
5813
|
+
(0, util.CD)();
|
|
5778
5814
|
context.runtimeConfig = (0, helper.PQ)(context.runtimeConfig);
|
|
5779
5815
|
const cleanupFns = [];
|
|
5780
5816
|
const { rpc } = createRuntimeRpc(createForksRpcOptions());
|
|
@@ -5799,7 +5835,7 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5799
5835
|
environment: 'node'
|
|
5800
5836
|
};
|
|
5801
5837
|
const { createRstestRuntime } = await Promise.all([
|
|
5802
|
-
__webpack_require__.e("
|
|
5838
|
+
__webpack_require__.e("208"),
|
|
5803
5839
|
__webpack_require__.e("867")
|
|
5804
5840
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/runtime/api/index.ts"));
|
|
5805
5841
|
const { install } = await __webpack_require__.e("64").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/source-map-support.js", 23));
|
|
@@ -5835,14 +5871,25 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5835
5871
|
process.off('unhandledRejection', unhandledRejection);
|
|
5836
5872
|
});
|
|
5837
5873
|
const { api, runner } = createRstestRuntime(workerState);
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5874
|
+
switch(testEnvironment){
|
|
5875
|
+
case 'node':
|
|
5876
|
+
break;
|
|
5877
|
+
case 'jsdom':
|
|
5878
|
+
{
|
|
5879
|
+
const { environment } = await __webpack_require__.e("965").then(__webpack_require__.bind(__webpack_require__, "./src/runtime/worker/env/jsdom.ts"));
|
|
5880
|
+
const { teardown } = await environment.setup(global, {});
|
|
5881
|
+
cleanupFns.push(()=>teardown(global));
|
|
5882
|
+
break;
|
|
5883
|
+
}
|
|
5884
|
+
case 'happy-dom':
|
|
5885
|
+
{
|
|
5886
|
+
const { environment } = await __webpack_require__.e("44").then(__webpack_require__.bind(__webpack_require__, "./src/runtime/worker/env/happyDom.ts"));
|
|
5887
|
+
const { teardown } = await environment.setup(global, {});
|
|
5888
|
+
cleanupFns.push(async ()=>await teardown(global));
|
|
5889
|
+
break;
|
|
5890
|
+
}
|
|
5891
|
+
default:
|
|
5892
|
+
throw new Error(`Unknown test environment: ${testEnvironment}`);
|
|
5846
5893
|
}
|
|
5847
5894
|
const rstestContext = {
|
|
5848
5895
|
global,
|
|
@@ -5910,7 +5957,7 @@ const runInPool = async (options)=>{
|
|
|
5910
5957
|
});
|
|
5911
5958
|
process.off('SIGTERM', onExit);
|
|
5912
5959
|
const teardown = async ()=>{
|
|
5913
|
-
await new Promise((resolve)=>(0,
|
|
5960
|
+
await new Promise((resolve)=>(0, util.BH)().setTimeout(resolve));
|
|
5914
5961
|
await Promise.all(cleanups.map((fn)=>fn()));
|
|
5915
5962
|
isTeardown = true;
|
|
5916
5963
|
process.once('SIGTERM', onExit);
|
|
@@ -5931,13 +5978,13 @@ const runInPool = async (options)=>{
|
|
|
5931
5978
|
return {
|
|
5932
5979
|
testPath,
|
|
5933
5980
|
tests,
|
|
5934
|
-
errors: (0, util.
|
|
5981
|
+
errors: (0, util.ov)(unhandledErrors)
|
|
5935
5982
|
};
|
|
5936
5983
|
} catch (err) {
|
|
5937
5984
|
return {
|
|
5938
5985
|
testPath,
|
|
5939
5986
|
tests: [],
|
|
5940
|
-
errors: (0, util.
|
|
5987
|
+
errors: (0, util.ov)(err)
|
|
5941
5988
|
};
|
|
5942
5989
|
} finally{
|
|
5943
5990
|
await teardown();
|
|
@@ -5967,7 +6014,7 @@ const runInPool = async (options)=>{
|
|
|
5967
6014
|
}, api);
|
|
5968
6015
|
if (unhandledErrors.length > 0) {
|
|
5969
6016
|
results.status = 'fail';
|
|
5970
|
-
results.errors = (results.errors || []).concat(...(0, util.
|
|
6017
|
+
results.errors = (results.errors || []).concat(...(0, util.ov)(unhandledErrors));
|
|
5971
6018
|
}
|
|
5972
6019
|
return results;
|
|
5973
6020
|
} catch (err) {
|
|
@@ -5976,7 +6023,7 @@ const runInPool = async (options)=>{
|
|
|
5976
6023
|
status: 'fail',
|
|
5977
6024
|
name: '',
|
|
5978
6025
|
results: [],
|
|
5979
|
-
errors: (0, util.
|
|
6026
|
+
errors: (0, util.ov)(err)
|
|
5980
6027
|
};
|
|
5981
6028
|
} finally{
|
|
5982
6029
|
await teardown();
|
package/dist-types/node.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
2
|
-
import type { SnapshotResult } from '@vitest/snapshot';
|
|
3
|
-
import type { SnapshotSummary } from '@vitest/snapshot';
|
|
4
2
|
|
|
5
3
|
declare type BuiltInReporterNames = keyof typeof reportersMap;
|
|
6
4
|
|
|
@@ -317,6 +315,34 @@ declare type RstestPoolOptions = {
|
|
|
317
315
|
|
|
318
316
|
declare type RstestPoolType = 'forks';
|
|
319
317
|
|
|
318
|
+
declare interface SnapshotResult {
|
|
319
|
+
filepath: string;
|
|
320
|
+
added: number;
|
|
321
|
+
fileDeleted: boolean;
|
|
322
|
+
matched: number;
|
|
323
|
+
unchecked: number;
|
|
324
|
+
uncheckedKeys: Array<string>;
|
|
325
|
+
unmatched: number;
|
|
326
|
+
updated: number;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
declare interface SnapshotSummary {
|
|
330
|
+
added: number;
|
|
331
|
+
didUpdate: boolean;
|
|
332
|
+
failure: boolean;
|
|
333
|
+
filesAdded: number;
|
|
334
|
+
filesRemoved: number;
|
|
335
|
+
filesRemovedList: Array<string>;
|
|
336
|
+
filesUnmatched: number;
|
|
337
|
+
filesUpdated: number;
|
|
338
|
+
matched: number;
|
|
339
|
+
total: number;
|
|
340
|
+
unchecked: number;
|
|
341
|
+
uncheckedKeysByFile: Array<UncheckedSnapshot>;
|
|
342
|
+
unmatched: number;
|
|
343
|
+
updated: number;
|
|
344
|
+
}
|
|
345
|
+
|
|
320
346
|
declare type SourceColumn = number;
|
|
321
347
|
|
|
322
348
|
declare type SourceLine = number;
|
|
@@ -400,6 +426,11 @@ declare class TraceMap implements SourceMap {
|
|
|
400
426
|
constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
|
|
401
427
|
}
|
|
402
428
|
|
|
429
|
+
declare interface UncheckedSnapshot {
|
|
430
|
+
filePath: string;
|
|
431
|
+
keys: Array<string>;
|
|
432
|
+
}
|
|
433
|
+
|
|
403
434
|
declare interface UserConsoleLog {
|
|
404
435
|
content: string;
|
|
405
436
|
name: string;
|