@rstest/core 0.3.4 → 0.4.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 +1 -13
- package/dist/{465.js → 0~120.js} +11 -11
- package/dist/{223.js → 0~223.js} +6 -2
- package/dist/{33.js → 0~33.js} +62 -0
- package/dist/0~414.js +16 -0
- package/dist/{607.js → 0~493.js} +27 -44
- package/dist/0~603.js +50 -0
- package/dist/{655.js → 0~655.js} +5 -5
- package/dist/{263.js → 0~669.js} +18 -17
- package/dist/0~691.js +38 -0
- package/dist/0~836.js +26 -0
- package/dist/{85.js → 0~85.js} +3 -16
- package/dist/{755.js → 0~873.js} +25 -16
- package/dist/{928.js → 0~928.js} +2 -10
- package/dist/{985.js → 0~938.js} +33 -16
- package/dist/{967.js → 0~967.js} +5 -2
- package/dist/{969.js → 0~969.js} +1 -1
- package/dist/{971.js → 0~971.js} +1 -1
- package/dist/index.js +971 -1137
- package/dist/worker.js +83 -40
- package/dist-types/index.d.ts +112 -9
- package/dist-types/worker.d.ts +85 -9
- package/package.json +9 -7
- /package/dist/{171.js → 0~171.js} +0 -0
- /package/dist/{350.js → 0~350.js} +0 -0
- /package/dist/{655.js.LICENSE.txt → 0~655.js.LICENSE.txt} +0 -0
- /package/dist/{711.js → 0~711.js} +0 -0
- /package/dist/{928.js.LICENSE.txt → 0~928.js.LICENSE.txt} +0 -0
package/dist/worker.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/*! For license information please see worker.js.LICENSE.txt */
|
|
2
2
|
import __rslib_shim_module__ from 'module';
|
|
3
3
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
4
|
-
import node_process from "node:process";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_chai__ from "chai";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__ from "node:assert";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__ from "node:console";
|
|
8
4
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
9
5
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
|
|
10
6
|
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
@@ -13,10 +9,11 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
|
13
9
|
import * as __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__ from "node:tty";
|
|
14
10
|
import * as __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__ from "node:util";
|
|
15
11
|
import * as __WEBPACK_EXTERNAL_MODULE_pathe__ from "pathe";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
12
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__ from "node:process";
|
|
13
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
14
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__ from "node:vm";
|
|
15
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__ from "node:v8";
|
|
16
|
+
import * as __WEBPACK_EXTERNAL_MODULE_birpc__ from "birpc";
|
|
20
17
|
var __webpack_modules__ = {
|
|
21
18
|
"../../node_modules/.pnpm/@jest+diff-sequences@30.0.1/node_modules/@jest/diff-sequences/build/index.js": function(module) {
|
|
22
19
|
/*!
|
|
@@ -335,7 +332,7 @@ var __webpack_modules__ = {
|
|
|
335
332
|
module.exports = __nested_webpack_exports__;
|
|
336
333
|
})();
|
|
337
334
|
},
|
|
338
|
-
"../../node_modules/.pnpm/@jest+get-type@30.0
|
|
335
|
+
"../../node_modules/.pnpm/@jest+get-type@30.1.0/node_modules/@jest/get-type/build/index.js": function(module) {
|
|
339
336
|
/*!
|
|
340
337
|
* /**
|
|
341
338
|
* * Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -2880,7 +2877,7 @@ var __webpack_modules__ = {
|
|
|
2880
2877
|
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
2881
2878
|
};
|
|
2882
2879
|
},
|
|
2883
|
-
"../../node_modules/.pnpm/jest-diff@30.
|
|
2880
|
+
"../../node_modules/.pnpm/jest-diff@30.1.2/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
2884
2881
|
/*!
|
|
2885
2882
|
* /**
|
|
2886
2883
|
* * Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -3744,7 +3741,7 @@ var __webpack_modules__ = {
|
|
|
3744
3741
|
}
|
|
3745
3742
|
});
|
|
3746
3743
|
var _chalk = _interopRequireDefault(__webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js"));
|
|
3747
|
-
var _getType = __webpack_require__("../../node_modules/.pnpm/@jest+get-type@30.0
|
|
3744
|
+
var _getType = __webpack_require__("../../node_modules/.pnpm/@jest+get-type@30.1.0/node_modules/@jest/get-type/build/index.js");
|
|
3748
3745
|
var _prettyFormat = __webpack_require__("../../node_modules/.pnpm/pretty-format@30.0.5/node_modules/pretty-format/build/index.js");
|
|
3749
3746
|
var _cleanupSemantic = __nested_webpack_require_48295__("./src/cleanupSemantic.ts");
|
|
3750
3747
|
var _constants = __nested_webpack_require_48295__("./src/constants.ts");
|
|
@@ -4976,7 +4973,7 @@ var __webpack_modules__ = {
|
|
|
4976
4973
|
});
|
|
4977
4974
|
var external_node_module_ = __webpack_require__("node:module");
|
|
4978
4975
|
var external_node_util_ = __webpack_require__("node:util");
|
|
4979
|
-
var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.
|
|
4976
|
+
var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.1.2/node_modules/jest-diff/build/index.js");
|
|
4980
4977
|
build.DIFF_DELETE;
|
|
4981
4978
|
build.DIFF_EQUAL;
|
|
4982
4979
|
build.DIFF_INSERT;
|
|
@@ -5066,10 +5063,8 @@ var __webpack_modules__ = {
|
|
|
5066
5063
|
"./src/utils/constants.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5067
5064
|
__webpack_require__.d(__webpack_exports__, {
|
|
5068
5065
|
TE: ()=>globalApis,
|
|
5069
|
-
q_: ()=>ROOT_SUITE_NAME
|
|
5070
|
-
vO: ()=>TEST_DELIMITER
|
|
5066
|
+
q_: ()=>ROOT_SUITE_NAME
|
|
5071
5067
|
});
|
|
5072
|
-
const TEST_DELIMITER = '>';
|
|
5073
5068
|
const ROOT_SUITE_NAME = 'Rstest:_internal_root_suite';
|
|
5074
5069
|
const globalApis = [
|
|
5075
5070
|
'test',
|
|
@@ -5099,7 +5094,7 @@ var __webpack_modules__ = {
|
|
|
5099
5094
|
__webpack_require__("pathe");
|
|
5100
5095
|
var picocolors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
5101
5096
|
var picocolors__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_2__);
|
|
5102
|
-
|
|
5097
|
+
__webpack_require__("./src/utils/constants.ts");
|
|
5103
5098
|
const isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj);
|
|
5104
5099
|
const castArray = (arr)=>{
|
|
5105
5100
|
if (void 0 === arr) return [];
|
|
@@ -5126,7 +5121,7 @@ var __webpack_modules__ = {
|
|
|
5126
5121
|
return time;
|
|
5127
5122
|
};
|
|
5128
5123
|
const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
|
|
5129
|
-
const getTaskNameWithPrefix = (test, delimiter =
|
|
5124
|
+
const getTaskNameWithPrefix = (test, delimiter = ">")=>getTaskNames(test).join(` ${delimiter} `);
|
|
5130
5125
|
const REGEXP_FLAG_PREFIX = 'RSTEST_REGEXP:';
|
|
5131
5126
|
const unwrapRegex = (value)=>{
|
|
5132
5127
|
if (value.startsWith(REGEXP_FLAG_PREFIX)) {
|
|
@@ -5147,19 +5142,36 @@ var __webpack_modules__ = {
|
|
|
5147
5142
|
};
|
|
5148
5143
|
};
|
|
5149
5144
|
},
|
|
5145
|
+
"./src/utils/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5146
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
5147
|
+
fN: ()=>helper.fN,
|
|
5148
|
+
Gv: ()=>helper.Gv,
|
|
5149
|
+
kV: ()=>helper.kV,
|
|
5150
|
+
q_: ()=>constants.q_,
|
|
5151
|
+
bg: ()=>helper.bg,
|
|
5152
|
+
yW: ()=>helper.yW
|
|
5153
|
+
});
|
|
5154
|
+
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
5155
|
+
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
5156
|
+
__webpack_require__("./src/utils/logger.ts");
|
|
5157
|
+
__webpack_require__("fs");
|
|
5158
|
+
__webpack_require__("node:fs/promises");
|
|
5159
|
+
__webpack_require__("node:module");
|
|
5160
|
+
__webpack_require__("pathe");
|
|
5161
|
+
},
|
|
5150
5162
|
"./src/utils/logger.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5151
5163
|
__webpack_require__.d(__webpack_exports__, {
|
|
5152
5164
|
vF: ()=>src_logger
|
|
5153
5165
|
});
|
|
5154
5166
|
var external_node_os_ = __webpack_require__("node:os");
|
|
5155
5167
|
var external_node_tty_ = __webpack_require__("node:tty");
|
|
5156
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args :
|
|
5168
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__["default"].argv) {
|
|
5157
5169
|
const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
|
|
5158
5170
|
const position = argv.indexOf(prefix + flag);
|
|
5159
5171
|
const terminatorPosition = argv.indexOf('--');
|
|
5160
5172
|
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
5161
5173
|
}
|
|
5162
|
-
const { env } =
|
|
5174
|
+
const { env } = __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__["default"];
|
|
5163
5175
|
let flagForceColor;
|
|
5164
5176
|
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
|
|
5165
5177
|
else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
|
|
@@ -5199,7 +5211,7 @@ var __webpack_modules__ = {
|
|
|
5199
5211
|
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
5200
5212
|
const min = forceColor || 0;
|
|
5201
5213
|
if ('dumb' === env.TERM) return min;
|
|
5202
|
-
if ('win32' ===
|
|
5214
|
+
if ('win32' === __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__["default"].platform) {
|
|
5203
5215
|
const osRelease = external_node_os_["default"].release().split('.');
|
|
5204
5216
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
5205
5217
|
return 1;
|
|
@@ -5431,16 +5443,7 @@ var __webpack_modules__ = {
|
|
|
5431
5443
|
"timers/promises": function(module) {
|
|
5432
5444
|
module.exports = require("timers/promises");
|
|
5433
5445
|
},
|
|
5434
|
-
|
|
5435
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_chai__;
|
|
5436
|
-
},
|
|
5437
|
-
"node:assert": function(module) {
|
|
5438
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__;
|
|
5439
|
-
},
|
|
5440
|
-
"node:console": function(module) {
|
|
5441
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__;
|
|
5442
|
-
},
|
|
5443
|
-
"node:fs": function(module) {
|
|
5446
|
+
fs: function(module) {
|
|
5444
5447
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
5445
5448
|
},
|
|
5446
5449
|
"node:fs/promises": function(module) {
|
|
@@ -5531,7 +5534,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
5531
5534
|
}, []));
|
|
5532
5535
|
})();
|
|
5533
5536
|
(()=>{
|
|
5534
|
-
__webpack_require__.u = (chunkId)=>"" + chunkId + ".js";
|
|
5537
|
+
__webpack_require__.u = (chunkId)=>"0~" + chunkId + ".js";
|
|
5535
5538
|
})();
|
|
5536
5539
|
(()=>{
|
|
5537
5540
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
@@ -5591,10 +5594,44 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
5591
5594
|
};
|
|
5592
5595
|
})();
|
|
5593
5596
|
__webpack_require__("./src/runtime/worker/setup.ts");
|
|
5597
|
+
var external_node_module_ = __webpack_require__("node:module");
|
|
5598
|
+
var utils = __webpack_require__("./src/utils/index.ts");
|
|
5599
|
+
const CoverageProviderMap = {
|
|
5600
|
+
istanbul: '@rstest/coverage-istanbul'
|
|
5601
|
+
};
|
|
5602
|
+
const loadCoverageProvider = async (options, root)=>{
|
|
5603
|
+
const rootPath = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(root).toString();
|
|
5604
|
+
const moduleName = CoverageProviderMap[options.provider || 'istanbul'];
|
|
5605
|
+
if (!moduleName) throw new Error(`Unknown coverage provider: ${options.provider}`);
|
|
5606
|
+
try {
|
|
5607
|
+
const require = (0, external_node_module_.createRequire)(rootPath);
|
|
5608
|
+
const modulePath = require.resolve(moduleName, {
|
|
5609
|
+
paths: [
|
|
5610
|
+
rootPath
|
|
5611
|
+
]
|
|
5612
|
+
});
|
|
5613
|
+
const { pluginCoverage, CoverageProvider } = await import((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(modulePath).toString());
|
|
5614
|
+
return {
|
|
5615
|
+
pluginCoverage,
|
|
5616
|
+
CoverageProvider
|
|
5617
|
+
};
|
|
5618
|
+
} catch {
|
|
5619
|
+
const error = new Error(`Failed to load coverage provider module: ${utils.yW.cyan(moduleName)} in ${utils.yW.underline(root)}, please make sure it is installed.\n`);
|
|
5620
|
+
error.stack = '';
|
|
5621
|
+
throw error;
|
|
5622
|
+
}
|
|
5623
|
+
};
|
|
5624
|
+
async function createCoverageProvider(options, root) {
|
|
5625
|
+
if (!options.enabled) return null;
|
|
5626
|
+
if (!options.provider || CoverageProviderMap[options.provider]) {
|
|
5627
|
+
const { CoverageProvider } = await loadCoverageProvider(options, root);
|
|
5628
|
+
return new CoverageProvider(options);
|
|
5629
|
+
}
|
|
5630
|
+
throw new Error(`Unknown coverage provider: ${options.provider}`);
|
|
5631
|
+
}
|
|
5594
5632
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
5595
5633
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
5596
5634
|
var util = __webpack_require__("./src/runtime/util.ts");
|
|
5597
|
-
var external_node_module_ = __webpack_require__("node:module");
|
|
5598
5635
|
var external_node_path_ = __webpack_require__("node:path");
|
|
5599
5636
|
var external_pathe_ = __webpack_require__("pathe");
|
|
5600
5637
|
var logger = __webpack_require__("./src/utils/logger.ts");
|
|
@@ -5641,7 +5678,7 @@ const asModule = async (something, defaultExport, context, unlinked)=>{
|
|
|
5641
5678
|
return m;
|
|
5642
5679
|
};
|
|
5643
5680
|
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
5644
|
-
const
|
|
5681
|
+
const worker_createRequire = (filename, distPath, rstestContext, assetFiles, interopDefault)=>{
|
|
5645
5682
|
const _require = (()=>{
|
|
5646
5683
|
try {
|
|
5647
5684
|
return (0, external_node_module_.createRequire)(filename);
|
|
@@ -5673,7 +5710,7 @@ const createRequire = (filename, distPath, rstestContext, assetFiles, interopDef
|
|
|
5673
5710
|
return require;
|
|
5674
5711
|
};
|
|
5675
5712
|
const defineRstestDynamicImport = ({ testPath, interopDefault, returnModule = false })=>async (specifier, importAttributes)=>{
|
|
5676
|
-
const resolvedPath = (0, external_node_path_.isAbsolute)(specifier) ? pathToFileURL(specifier) : import.meta.resolve(specifier, pathToFileURL(testPath));
|
|
5713
|
+
const resolvedPath = (0, external_node_path_.isAbsolute)(specifier) ? (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(specifier) : import.meta.resolve(specifier, (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(testPath));
|
|
5677
5714
|
const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
|
|
5678
5715
|
if (importAttributes?.with?.rstest) delete importAttributes.with.rstest;
|
|
5679
5716
|
const importedModule = await import(modulePath, importAttributes);
|
|
@@ -5720,7 +5757,7 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
|
|
|
5720
5757
|
const context = {
|
|
5721
5758
|
module: localModule,
|
|
5722
5759
|
exports: localModule.exports,
|
|
5723
|
-
require:
|
|
5760
|
+
require: worker_createRequire(testPath, distPath, rstestContext, assetFiles, interopDefault),
|
|
5724
5761
|
__rstest_dynamic_import__: defineRstestDynamicImport({
|
|
5725
5762
|
testPath,
|
|
5726
5763
|
interopDefault
|
|
@@ -5731,7 +5768,7 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
|
|
|
5731
5768
|
};
|
|
5732
5769
|
const codeDefinition = `'use strict';(${Object.keys(context).join(',')})=>{`;
|
|
5733
5770
|
const code = `${codeDefinition}${codeContent}\n}`;
|
|
5734
|
-
const fn =
|
|
5771
|
+
const fn = __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__["default"].runInThisContext(code, {
|
|
5735
5772
|
filename: distPath,
|
|
5736
5773
|
lineOffset: 0,
|
|
5737
5774
|
columnOffset: -codeDefinition.length,
|
|
@@ -5762,7 +5799,7 @@ const processSend = process.send.bind(process);
|
|
|
5762
5799
|
const processOn = process.on.bind(process);
|
|
5763
5800
|
const processOff = process.off.bind(process);
|
|
5764
5801
|
const dispose = [];
|
|
5765
|
-
function createForksRpcOptions(nodeV8 =
|
|
5802
|
+
function createForksRpcOptions(nodeV8 = __WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__["default"]) {
|
|
5766
5803
|
return {
|
|
5767
5804
|
serialize: nodeV8.serialize,
|
|
5768
5805
|
deserialize: (v)=>nodeV8.deserialize(Buffer.from(v)),
|
|
@@ -5780,12 +5817,12 @@ function createForksRpcOptions(nodeV8 = node_v8) {
|
|
|
5780
5817
|
};
|
|
5781
5818
|
}
|
|
5782
5819
|
function createRuntimeRpc(options) {
|
|
5783
|
-
const rpc = createBirpc({}, options);
|
|
5820
|
+
const rpc = (0, __WEBPACK_EXTERNAL_MODULE_birpc__.createBirpc)({}, options);
|
|
5784
5821
|
return {
|
|
5785
5822
|
rpc
|
|
5786
5823
|
};
|
|
5787
5824
|
}
|
|
5788
|
-
var external_node_fs_ = __webpack_require__("
|
|
5825
|
+
var external_node_fs_ = __webpack_require__("fs");
|
|
5789
5826
|
class NodeSnapshotEnvironment {
|
|
5790
5827
|
constructor(options = {}){
|
|
5791
5828
|
this.options = options;
|
|
@@ -5839,7 +5876,7 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5839
5876
|
const { rpc } = createRuntimeRpc(createForksRpcOptions());
|
|
5840
5877
|
const { runtimeConfig: { globals, printConsoleTrace, disableConsoleIntercept, testEnvironment } } = context;
|
|
5841
5878
|
if (!disableConsoleIntercept) {
|
|
5842
|
-
const { createCustomConsole } = await __webpack_require__.e("
|
|
5879
|
+
const { createCustomConsole } = await __webpack_require__.e("493").then(__webpack_require__.bind(__webpack_require__, "./src/runtime/worker/console.ts"));
|
|
5843
5880
|
global.console = createCustomConsole({
|
|
5844
5881
|
rpc,
|
|
5845
5882
|
testPath,
|
|
@@ -6018,6 +6055,8 @@ const runInPool = async (options)=>{
|
|
|
6018
6055
|
}
|
|
6019
6056
|
try {
|
|
6020
6057
|
const { rstestContext, runner, rpc, api, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
|
|
6058
|
+
const coverageProvider = await createCoverageProvider(options.context.runtimeConfig.coverage || {}, options.context.rootPath);
|
|
6059
|
+
if (coverageProvider) coverageProvider.init();
|
|
6021
6060
|
cleanups.push(cleanup);
|
|
6022
6061
|
await loadFiles({
|
|
6023
6062
|
rstestContext,
|
|
@@ -6033,6 +6072,10 @@ const runInPool = async (options)=>{
|
|
|
6033
6072
|
await rpc.onTestFileStart(test);
|
|
6034
6073
|
},
|
|
6035
6074
|
onTestFileResult: async (test)=>{
|
|
6075
|
+
if (coverageProvider) {
|
|
6076
|
+
const coverageMap = coverageProvider.collect();
|
|
6077
|
+
if (coverageMap) test.coverage = coverageMap.toJSON();
|
|
6078
|
+
}
|
|
6036
6079
|
await rpc.onTestFileResult(test);
|
|
6037
6080
|
},
|
|
6038
6081
|
onTestCaseResult: async (result)=>{
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { assert as assert_2 } from 'chai';
|
|
2
|
+
import type { CoverageMap } from 'istanbul-lib-coverage';
|
|
3
|
+
import type { ReportOptions } from 'istanbul-reports';
|
|
2
4
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
5
|
+
import { RsbuildPlugin } from '@rsbuild/core';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
@@ -328,6 +331,80 @@ declare class CounterMap<K> extends DefaultMap<K, number> {
|
|
|
328
331
|
total(): number;
|
|
329
332
|
}
|
|
330
333
|
|
|
334
|
+
export declare type CoverageOptions = {
|
|
335
|
+
/**
|
|
336
|
+
* Enable coverage collection.
|
|
337
|
+
* @default false
|
|
338
|
+
*/
|
|
339
|
+
enabled?: boolean;
|
|
340
|
+
/**
|
|
341
|
+
* A list of glob patterns that should be excluded from coverage collection.
|
|
342
|
+
*
|
|
343
|
+
* This option accepts an array of wax(https://crates.io/crates/wax)-compatible glob patterns
|
|
344
|
+
*
|
|
345
|
+
* @default ['**\/node_modules/**',
|
|
346
|
+
* '**\/dist/**',
|
|
347
|
+
* '**\/test/**',
|
|
348
|
+
* '**\/__tests__/**',
|
|
349
|
+
* '**\/*.{test,spec}.?(c|m)[jt]s?(x)',
|
|
350
|
+
* '**\/__mocks__/**'
|
|
351
|
+
* ]
|
|
352
|
+
*/
|
|
353
|
+
exclude?: string[];
|
|
354
|
+
/**
|
|
355
|
+
* The provider to use for coverage collection.
|
|
356
|
+
* @default 'istanbul'
|
|
357
|
+
*/
|
|
358
|
+
provider?: 'istanbul';
|
|
359
|
+
/**
|
|
360
|
+
* The reporters to use for coverage collection.
|
|
361
|
+
* @default ['text', 'html', 'clover', 'json']
|
|
362
|
+
*/
|
|
363
|
+
reporters?: (keyof ReportOptions | ReportWithOptions)[];
|
|
364
|
+
/**
|
|
365
|
+
* The directory to store coverage reports.
|
|
366
|
+
* @default './coverage'
|
|
367
|
+
*/
|
|
368
|
+
reportsDirectory?: string;
|
|
369
|
+
/**
|
|
370
|
+
* Whether to clean the coverage directory before running tests.
|
|
371
|
+
* @default true
|
|
372
|
+
*/
|
|
373
|
+
clean?: boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Coverage thresholds
|
|
376
|
+
*
|
|
377
|
+
* @default undefined
|
|
378
|
+
*/
|
|
379
|
+
thresholds?: CoverageThresholds;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
export declare class CoverageProvider {
|
|
383
|
+
constructor(options: CoverageOptions);
|
|
384
|
+
/**
|
|
385
|
+
* Initialize coverage collection
|
|
386
|
+
*/
|
|
387
|
+
init(): void;
|
|
388
|
+
/**
|
|
389
|
+
* Collect coverage data from global coverage object
|
|
390
|
+
*/
|
|
391
|
+
collect(): CoverageMap | null;
|
|
392
|
+
/**
|
|
393
|
+
* Create a new coverage map
|
|
394
|
+
*/
|
|
395
|
+
createCoverageMap(): CoverageMap;
|
|
396
|
+
/**
|
|
397
|
+
* Generate coverage reports
|
|
398
|
+
*/
|
|
399
|
+
generateReports(coverageMap: CoverageMap, options: CoverageOptions): Promise<void>;
|
|
400
|
+
/**
|
|
401
|
+
* Clean up coverage data
|
|
402
|
+
*/
|
|
403
|
+
cleanup(): void;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
declare type CoverageThresholds = Thresholds;
|
|
407
|
+
|
|
331
408
|
declare interface CustomMatcher {
|
|
332
409
|
/**
|
|
333
410
|
* Checks that a value satisfies a custom matcher function.
|
|
@@ -1589,18 +1666,23 @@ declare interface NewPlugin {
|
|
|
1589
1666
|
test: Test;
|
|
1590
1667
|
}
|
|
1591
1668
|
|
|
1592
|
-
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects'>> & {
|
|
1669
|
+
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage'>> & {
|
|
1593
1670
|
[key in OptionalKeys]?: RstestConfig[key];
|
|
1594
1671
|
} & {
|
|
1595
1672
|
pool: RstestPoolOptions;
|
|
1673
|
+
coverage: NormalizedCoverageOptions;
|
|
1674
|
+
};
|
|
1675
|
+
|
|
1676
|
+
export declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, 'thresholds'>> & {
|
|
1677
|
+
thresholds?: CoverageThresholds;
|
|
1596
1678
|
};
|
|
1597
1679
|
|
|
1598
1680
|
declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
|
|
1599
1681
|
|
|
1600
1682
|
declare type NormalizedProcedure_2<T extends Procedure_2> = (...args: Parameters<T>) => ReturnType<T>;
|
|
1601
1683
|
|
|
1602
|
-
declare type NormalizedProjectConfig = Required<Omit<
|
|
1603
|
-
[key in OptionalKeys]?:
|
|
1684
|
+
declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool'>> & {
|
|
1685
|
+
[key in OptionalKeys]?: NormalizedConfig[key];
|
|
1604
1686
|
};
|
|
1605
1687
|
|
|
1606
1688
|
declare interface OldPlugin {
|
|
@@ -1676,11 +1758,12 @@ declare type Procedure = (...args: any[]) => any;
|
|
|
1676
1758
|
|
|
1677
1759
|
declare type Procedure_2 = (...args: any[]) => any;
|
|
1678
1760
|
|
|
1679
|
-
export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate'>;
|
|
1761
|
+
export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage'>;
|
|
1680
1762
|
|
|
1681
1763
|
declare type ProjectContext = {
|
|
1682
1764
|
name: string;
|
|
1683
1765
|
environmentName: string;
|
|
1766
|
+
/** The root path of current project. */
|
|
1684
1767
|
rootPath: string;
|
|
1685
1768
|
configFilePath?: string;
|
|
1686
1769
|
normalizedConfig: NormalizedProjectConfig;
|
|
@@ -1754,6 +1837,8 @@ declare const reportersMap: {
|
|
|
1754
1837
|
|
|
1755
1838
|
declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
|
|
1756
1839
|
|
|
1840
|
+
declare type ReportWithOptions<Name extends keyof ReportOptions = keyof ReportOptions> = Name extends keyof ReportOptions ? [Name, Partial<ReportOptions[Name]>] : [Name, Record<string, unknown>];
|
|
1841
|
+
|
|
1757
1842
|
declare type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
|
|
1758
1843
|
|
|
1759
1844
|
declare type RoArray<T> = Ro<T>[];
|
|
@@ -1764,6 +1849,8 @@ declare type RoObject<T> = {
|
|
|
1764
1849
|
|
|
1765
1850
|
export declare const rs: RstestUtilities;
|
|
1766
1851
|
|
|
1852
|
+
export { RsbuildPlugin }
|
|
1853
|
+
|
|
1767
1854
|
declare type Rstest = RunnerAPI & {
|
|
1768
1855
|
expect: RstestExpect;
|
|
1769
1856
|
assert: typeof assert_2;
|
|
@@ -1923,6 +2010,10 @@ export declare interface RstestConfig {
|
|
|
1923
2010
|
* Custom handler for console log in tests
|
|
1924
2011
|
*/
|
|
1925
2012
|
onConsoleLog?: (content: string) => boolean | void;
|
|
2013
|
+
/**
|
|
2014
|
+
* Coverage options
|
|
2015
|
+
*/
|
|
2016
|
+
coverage?: CoverageOptions;
|
|
1926
2017
|
plugins?: RsbuildConfig['plugins'];
|
|
1927
2018
|
source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
|
|
1928
2019
|
performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
|
|
@@ -1941,7 +2032,7 @@ export declare type RstestConfigSyncFn = () => RstestConfig;
|
|
|
1941
2032
|
declare type RstestContext = {
|
|
1942
2033
|
/** The Rstest core version. */
|
|
1943
2034
|
version: string;
|
|
1944
|
-
/** The root path of
|
|
2035
|
+
/** The root path of rstest. */
|
|
1945
2036
|
rootPath: string;
|
|
1946
2037
|
/** The original Rstest config passed from the createRstest method. */
|
|
1947
2038
|
originalConfig: Readonly<RstestConfig>;
|
|
@@ -1958,8 +2049,9 @@ declare type RstestContext = {
|
|
|
1958
2049
|
/**
|
|
1959
2050
|
* The command type.
|
|
1960
2051
|
*
|
|
1961
|
-
* -
|
|
1962
|
-
* -
|
|
2052
|
+
* - run: `rstest`
|
|
2053
|
+
* - dev: `rstest dev` or watch mode
|
|
2054
|
+
* - list: `rstest list`
|
|
1963
2055
|
*/
|
|
1964
2056
|
command: RstestCommand;
|
|
1965
2057
|
reporters: Reporter[];
|
|
@@ -1970,7 +2062,7 @@ declare type RstestExpect = ExpectStatic;
|
|
|
1970
2062
|
|
|
1971
2063
|
declare type RstestPoolOptions = {
|
|
1972
2064
|
/** Pool used to run tests in. */
|
|
1973
|
-
type
|
|
2065
|
+
type?: RstestPoolType;
|
|
1974
2066
|
/** Maximum number or percentage of workers to run tests in. */
|
|
1975
2067
|
maxWorkers?: number | string;
|
|
1976
2068
|
/** Minimum number or percentage of workers to run tests in. */
|
|
@@ -2119,7 +2211,7 @@ declare type RunnerAPI = {
|
|
|
2119
2211
|
onTestFailed: (fn: OnTestFailedHandler, timeout?: number) => void;
|
|
2120
2212
|
};
|
|
2121
2213
|
|
|
2122
|
-
declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout'>;
|
|
2214
|
+
declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout' | 'coverage'>;
|
|
2123
2215
|
|
|
2124
2216
|
declare type RuntimeOptions = Partial<Pick<RuntimeConfig, 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'maxConcurrency' | 'retry'>>;
|
|
2125
2217
|
|
|
@@ -2397,6 +2489,17 @@ export declare type TestResult = {
|
|
|
2397
2489
|
|
|
2398
2490
|
declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
|
|
2399
2491
|
|
|
2492
|
+
declare type Thresholds = {
|
|
2493
|
+
/** Thresholds for statements */
|
|
2494
|
+
statements?: number;
|
|
2495
|
+
/** Thresholds for functions */
|
|
2496
|
+
functions?: number;
|
|
2497
|
+
/** Thresholds for branches */
|
|
2498
|
+
branches?: number;
|
|
2499
|
+
/** Thresholds for lines */
|
|
2500
|
+
lines?: number;
|
|
2501
|
+
};
|
|
2502
|
+
|
|
2400
2503
|
declare class TraceMap implements SourceMap {
|
|
2401
2504
|
version: SourceMapV3['version'];
|
|
2402
2505
|
file: SourceMapV3['file'];
|