@rstest/core 0.1.2 → 0.2.0
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 +26 -0
- package/bin/rstest.js +1 -1
- package/dist/208.js +1 -1
- package/dist/25.js +91 -0
- package/dist/285.js +12 -9
- package/dist/355.js +1 -1
- package/dist/359.js +13 -9
- package/dist/64.js +1 -1
- package/dist/668.js +1439 -0
- package/dist/668.js.LICENSE.txt +1 -0
- package/dist/813.js +1 -1
- package/dist/854.js +72 -55
- package/dist/867.js +1 -1
- package/dist/920.js +321 -0
- package/dist/{cli.js → index.js} +688 -609
- package/dist/worker.js +11 -10
- package/dist-types/{public.d.ts → index.d.ts} +25 -17
- package/dist-types/worker.d.ts +6 -2
- package/package.json +10 -13
- package/dist/629.js +0 -84
- package/dist/node.js +0 -2
- package/dist/public.js +0 -6
- package/dist-types/cli.d.ts +0 -3
- package/dist-types/node.d.ts +0 -450
package/LICENSE.md
CHANGED
|
@@ -592,6 +592,32 @@ Licensed under MIT license.
|
|
|
592
592
|
>
|
|
593
593
|
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
594
594
|
|
|
595
|
+
### chokidar
|
|
596
|
+
|
|
597
|
+
Licensed under MIT license in the repository at git+https://github.com/paulmillr/chokidar.git.
|
|
598
|
+
|
|
599
|
+
> The MIT License (MIT)
|
|
600
|
+
>
|
|
601
|
+
> Copyright (c) 2012 Paul Miller (https://paulmillr.com), Elan Shanker
|
|
602
|
+
>
|
|
603
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
604
|
+
> of this software and associated documentation files (the “Software”), to deal
|
|
605
|
+
> in the Software without restriction, including without limitation the rights
|
|
606
|
+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
607
|
+
> copies of the Software, and to permit persons to whom the Software is
|
|
608
|
+
> furnished to do so, subject to the following conditions:
|
|
609
|
+
>
|
|
610
|
+
> The above copyright notice and this permission notice shall be included in
|
|
611
|
+
> all copies or substantial portions of the Software.
|
|
612
|
+
>
|
|
613
|
+
> THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
614
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
615
|
+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
616
|
+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
617
|
+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
618
|
+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
619
|
+
> THE SOFTWARE.
|
|
620
|
+
|
|
595
621
|
### color-convert
|
|
596
622
|
|
|
597
623
|
Licensed under MIT license.
|
package/bin/rstest.js
CHANGED
package/dist/208.js
CHANGED
|
@@ -8174,7 +8174,7 @@ ${printReceived(actual)}`
|
|
|
8174
8174
|
for (let [r, t] of h)u[r] = e ? g(d(t[0]), d(t[1]), t[2]) : a;
|
|
8175
8175
|
return u;
|
|
8176
8176
|
}
|
|
8177
|
-
var external_node_tty_ = __webpack_require__("
|
|
8177
|
+
var external_node_tty_ = __webpack_require__("tty");
|
|
8178
8178
|
var node_r = void 0 !== process.env.FORCE_TTY || (0, external_node_tty_.isatty)(1);
|
|
8179
8179
|
var node_u = p(node_r);
|
|
8180
8180
|
},
|
package/dist/25.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
export const __webpack_ids__ = [
|
|
4
|
+
"25"
|
|
5
|
+
];
|
|
6
|
+
export const __webpack_modules__ = {
|
|
7
|
+
"./src/core/restart.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
8
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
onBeforeRestart: ()=>onBeforeRestart,
|
|
10
|
+
watchFilesForRestart: ()=>watchFilesForRestart
|
|
11
|
+
});
|
|
12
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
13
|
+
var commands = __webpack_require__("./src/cli/commands.ts");
|
|
14
|
+
var utils = __webpack_require__("./src/utils/index.ts");
|
|
15
|
+
const GLOB_REGEX = /[*?{}[\]()!@+|]/;
|
|
16
|
+
const isGlob = (str)=>GLOB_REGEX.test(str);
|
|
17
|
+
async function createChokidar(pathOrGlobs, root, options) {
|
|
18
|
+
const chokidar = await __webpack_require__.e("668").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"));
|
|
19
|
+
const watchFiles = new Set();
|
|
20
|
+
const globPatterns = pathOrGlobs.filter((pathOrGlob)=>{
|
|
21
|
+
if (isGlob(pathOrGlob)) return true;
|
|
22
|
+
watchFiles.add(pathOrGlob);
|
|
23
|
+
return false;
|
|
24
|
+
});
|
|
25
|
+
if (globPatterns.length) {
|
|
26
|
+
const { glob } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/tinyglobby@0.2.14/node_modules/tinyglobby/dist/index.mjs"));
|
|
27
|
+
const files = await glob(globPatterns, {
|
|
28
|
+
cwd: root,
|
|
29
|
+
absolute: true
|
|
30
|
+
});
|
|
31
|
+
for (const file of files)watchFiles.add(file);
|
|
32
|
+
}
|
|
33
|
+
return chokidar.watch(Array.from(watchFiles), options);
|
|
34
|
+
}
|
|
35
|
+
let cleaners = [];
|
|
36
|
+
const onBeforeRestart = (cleaner)=>{
|
|
37
|
+
cleaners.push(cleaner);
|
|
38
|
+
};
|
|
39
|
+
const clearConsole = ()=>{
|
|
40
|
+
if ((0, utils._l)() && !process.env.DEBUG) process.stdout.write('\x1B[H\x1B[2J');
|
|
41
|
+
};
|
|
42
|
+
const beforeRestart = async ({ filePath, clear = true })=>{
|
|
43
|
+
if (clear) clearConsole();
|
|
44
|
+
if (filePath) {
|
|
45
|
+
const filename = external_node_path_["default"].basename(filePath);
|
|
46
|
+
utils.kg.info(`restarting Rstest as ${utils.$_.yellow(filename)} changed\n`);
|
|
47
|
+
} else utils.kg.info('restarting Rstest...\n');
|
|
48
|
+
for (const cleaner of cleaners)await cleaner();
|
|
49
|
+
cleaners = [];
|
|
50
|
+
};
|
|
51
|
+
const restart = async ({ filePath, clear = true, options, filters })=>{
|
|
52
|
+
await beforeRestart({
|
|
53
|
+
filePath,
|
|
54
|
+
clear
|
|
55
|
+
});
|
|
56
|
+
await (0, commands.mR)({
|
|
57
|
+
options,
|
|
58
|
+
filters,
|
|
59
|
+
command: 'watch'
|
|
60
|
+
});
|
|
61
|
+
return true;
|
|
62
|
+
};
|
|
63
|
+
async function watchFilesForRestart({ rstest, watchOptions, options, filters }) {
|
|
64
|
+
if (!rstest.context.configFilePath) return;
|
|
65
|
+
const root = rstest.context.rootPath;
|
|
66
|
+
const watcher = await createChokidar([
|
|
67
|
+
rstest.context.configFilePath
|
|
68
|
+
], root, {
|
|
69
|
+
ignoreInitial: true,
|
|
70
|
+
ignorePermissionErrors: true,
|
|
71
|
+
...watchOptions
|
|
72
|
+
});
|
|
73
|
+
let restarting = false;
|
|
74
|
+
const onChange = async (filePath)=>{
|
|
75
|
+
if (restarting) return;
|
|
76
|
+
restarting = true;
|
|
77
|
+
const restarted = await restart({
|
|
78
|
+
options,
|
|
79
|
+
filters,
|
|
80
|
+
filePath
|
|
81
|
+
});
|
|
82
|
+
if (restarted) await watcher.close();
|
|
83
|
+
else utils.kg.error('Restart failed');
|
|
84
|
+
restarting = false;
|
|
85
|
+
};
|
|
86
|
+
watcher.on('add', onChange);
|
|
87
|
+
watcher.on('change', onChange);
|
|
88
|
+
watcher.on('unlink', onChange);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
package/dist/285.js
CHANGED
|
@@ -8,24 +8,24 @@ export const __webpack_modules__ = {
|
|
|
8
8
|
__webpack_require__.d(__webpack_exports__, {
|
|
9
9
|
listTests: ()=>listTests
|
|
10
10
|
});
|
|
11
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
|
|
11
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
12
12
|
var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
|
|
13
13
|
var _pool__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/pool/index.ts");
|
|
14
14
|
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
|
15
15
|
var _rsbuild__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/core/rsbuild.ts");
|
|
16
|
-
async function listTests(context,
|
|
16
|
+
async function listTests(context, { filesOnly, json }) {
|
|
17
17
|
const { normalizedConfig: { include, exclude, root, name, setupFiles: setups, includeSource }, rootPath } = context;
|
|
18
18
|
const testEntries = await (0, _utils__WEBPACK_IMPORTED_MODULE_3__.GL)({
|
|
19
19
|
include,
|
|
20
20
|
exclude,
|
|
21
21
|
root,
|
|
22
|
-
fileFilters,
|
|
22
|
+
fileFilters: context.fileFilters || [],
|
|
23
23
|
includeSource
|
|
24
24
|
});
|
|
25
25
|
const globTestSourceEntries = async ()=>testEntries;
|
|
26
26
|
const setupFiles = (0, _utils__WEBPACK_IMPORTED_MODULE_3__.aA)(setups, rootPath);
|
|
27
27
|
const rsbuildInstance = await (0, _rsbuild__WEBPACK_IMPORTED_MODULE_4__.z)(context, globTestSourceEntries, setupFiles);
|
|
28
|
-
const getRsbuildStats = await (0, _rsbuild__WEBPACK_IMPORTED_MODULE_4__.r)({
|
|
28
|
+
const { getRsbuildStats, closeServer } = await (0, _rsbuild__WEBPACK_IMPORTED_MODULE_4__.r)({
|
|
29
29
|
name,
|
|
30
30
|
globTestSourceEntries,
|
|
31
31
|
normalizedConfig: context.normalizedConfig,
|
|
@@ -33,15 +33,18 @@ export const __webpack_modules__ = {
|
|
|
33
33
|
rsbuildInstance,
|
|
34
34
|
rootPath
|
|
35
35
|
});
|
|
36
|
-
const { entries, setupEntries, assetFiles, sourceMaps,
|
|
36
|
+
const { entries, setupEntries, assetFiles, sourceMaps, getSourcemap } = await getRsbuildStats();
|
|
37
37
|
const pool = await (0, _pool__WEBPACK_IMPORTED_MODULE_2__.K)({
|
|
38
|
+
context
|
|
39
|
+
});
|
|
40
|
+
const list = await pool.collectTests({
|
|
41
|
+
context,
|
|
38
42
|
entries,
|
|
39
43
|
sourceMaps,
|
|
40
44
|
setupEntries,
|
|
41
45
|
assetFiles,
|
|
42
|
-
context
|
|
46
|
+
updateSnapshot: context.snapshotManager.options.updateSnapshot
|
|
43
47
|
});
|
|
44
|
-
const list = await pool.collectTests();
|
|
45
48
|
const tests = [];
|
|
46
49
|
const traverseTests = (test)=>{
|
|
47
50
|
if ([
|
|
@@ -68,7 +71,7 @@ export const __webpack_modules__ = {
|
|
|
68
71
|
for (const error of file.errors)await printError(error, getSourcemap, rootPath);
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
|
-
await
|
|
74
|
+
await closeServer();
|
|
72
75
|
await pool.close();
|
|
73
76
|
return;
|
|
74
77
|
}
|
|
@@ -94,7 +97,7 @@ export const __webpack_modules__ = {
|
|
|
94
97
|
const shortPath = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.relative)(rootPath, test.file);
|
|
95
98
|
_utils__WEBPACK_IMPORTED_MODULE_3__.kg.log(test.name ? `${_utils__WEBPACK_IMPORTED_MODULE_3__.$_.dim(`${shortPath} > `)}${test.name}` : (0, _utils__WEBPACK_IMPORTED_MODULE_3__.aj)(shortPath));
|
|
96
99
|
}
|
|
97
|
-
await
|
|
100
|
+
await closeServer();
|
|
98
101
|
await pool.close();
|
|
99
102
|
}
|
|
100
103
|
}
|
package/dist/355.js
CHANGED
|
@@ -9,7 +9,7 @@ export const __webpack_modules__ = {
|
|
|
9
9
|
parseErrorStacktrace: ()=>parseErrorStacktrace,
|
|
10
10
|
printError: ()=>printError
|
|
11
11
|
});
|
|
12
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
|
|
12
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
13
13
|
var _jridgewell_trace_mapping__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.29/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs");
|
|
14
14
|
var stacktrace_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
|
|
15
15
|
var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
|
package/dist/359.js
CHANGED
|
@@ -256,7 +256,7 @@ export const __webpack_modules__ = {
|
|
|
256
256
|
this.windowHeight = 0;
|
|
257
257
|
}
|
|
258
258
|
interceptStream(stream, type) {
|
|
259
|
-
const original = stream.write;
|
|
259
|
+
const original = stream.write.bind(stream);
|
|
260
260
|
stream.write = (chunk, _, callback)=>{
|
|
261
261
|
if (chunk) if (this.finished) this.write(chunk.toString(), type);
|
|
262
262
|
else this.buffer.push({
|
|
@@ -411,7 +411,7 @@ export const __webpack_modules__ = {
|
|
|
411
411
|
};
|
|
412
412
|
const logFileTitle = (test, relativePath, slowTestThreshold, alwaysShowTime = false)=>{
|
|
413
413
|
let title = ` ${utils.$_.bold(statusColorfulStr[test.status])} ${(0, utils.aj)(relativePath)}`;
|
|
414
|
-
const formatDuration = (duration)=>utils.$_[duration > slowTestThreshold ? 'yellow' : 'green'](
|
|
414
|
+
const formatDuration = (duration)=>utils.$_[duration > slowTestThreshold ? 'yellow' : 'green']((0, utils.AS)(duration));
|
|
415
415
|
title += ` ${utils.$_.gray(`(${test.results.length})`)}`;
|
|
416
416
|
const isTooSlow = test.duration && test.duration > slowTestThreshold;
|
|
417
417
|
if (alwaysShowTime || isTooSlow) title += ` ${formatDuration(test.duration)}`;
|
|
@@ -569,7 +569,7 @@ export const __webpack_modules__ = {
|
|
|
569
569
|
return result;
|
|
570
570
|
}
|
|
571
571
|
function createContext(options, userConfig) {
|
|
572
|
-
const { cwd, command } = options;
|
|
572
|
+
const { cwd, command, fileFilters, configFilePath } = options;
|
|
573
573
|
const rootPath = userConfig.root ? (0, helper.ZY)(cwd, userConfig.root) : cwd;
|
|
574
574
|
const rstestConfig = (0, src_config.hY)(userConfig);
|
|
575
575
|
const reporters = 'list' !== command ? createReporters(rstestConfig.reporters, {
|
|
@@ -580,33 +580,37 @@ export const __webpack_modules__ = {
|
|
|
580
580
|
updateSnapshot: rstestConfig.update ? 'all' : external_std_env_.isCI ? 'none' : 'new'
|
|
581
581
|
});
|
|
582
582
|
return {
|
|
583
|
+
configFilePath,
|
|
583
584
|
command,
|
|
584
|
-
version: "0.
|
|
585
|
+
version: "0.2.0",
|
|
585
586
|
rootPath,
|
|
586
587
|
reporters,
|
|
588
|
+
fileFilters,
|
|
587
589
|
snapshotManager,
|
|
588
590
|
originalConfig: userConfig,
|
|
589
591
|
normalizedConfig: rstestConfig
|
|
590
592
|
};
|
|
591
593
|
}
|
|
592
|
-
function createRstest(config, command, fileFilters) {
|
|
594
|
+
function createRstest({ config, configFilePath }, command, fileFilters) {
|
|
593
595
|
const context = createContext({
|
|
594
596
|
cwd: process.cwd(),
|
|
595
|
-
command
|
|
597
|
+
command,
|
|
598
|
+
fileFilters,
|
|
599
|
+
configFilePath
|
|
596
600
|
}, config);
|
|
597
601
|
const runTests = async ()=>{
|
|
598
602
|
const { runTests } = await Promise.all([
|
|
599
603
|
__webpack_require__.e("854"),
|
|
600
|
-
__webpack_require__.e("
|
|
604
|
+
__webpack_require__.e("920")
|
|
601
605
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/core/runTests.ts"));
|
|
602
|
-
await runTests(context
|
|
606
|
+
await runTests(context);
|
|
603
607
|
};
|
|
604
608
|
const listTests = async (options)=>{
|
|
605
609
|
const { listTests } = await Promise.all([
|
|
606
610
|
__webpack_require__.e("854"),
|
|
607
611
|
__webpack_require__.e("285")
|
|
608
612
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/core/listTests.ts"));
|
|
609
|
-
await listTests(context,
|
|
613
|
+
await listTests(context, options);
|
|
610
614
|
};
|
|
611
615
|
return {
|
|
612
616
|
context,
|
package/dist/64.js
CHANGED
|
@@ -40,7 +40,7 @@ export const __webpack_modules__ = {
|
|
|
40
40
|
var path = __webpack_require__("node:path");
|
|
41
41
|
var fs;
|
|
42
42
|
try {
|
|
43
|
-
fs = __webpack_require__("fs");
|
|
43
|
+
fs = __webpack_require__("node:fs");
|
|
44
44
|
if (!fs.existsSync || !fs.readFileSync) fs = null;
|
|
45
45
|
} catch (err) {}
|
|
46
46
|
var bufferFrom = __webpack_require__("../../node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/index.js");
|