@rstest/core 0.6.1 → 0.6.3

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/0~493.js DELETED
@@ -1,126 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import { AssertionError, strict } from "node:assert";
4
- import { Console } from "node:console";
5
- export const __webpack_id__ = "493";
6
- export const __webpack_ids__ = [
7
- "493"
8
- ];
9
- export const __webpack_modules__ = {
10
- "./src/runtime/worker/console.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
11
- __webpack_require__.d(__webpack_exports__, {
12
- createCustomConsole: ()=>createCustomConsole
13
- });
14
- var external_node_util_ = __webpack_require__("node:util");
15
- var utils = __webpack_require__("./src/utils/index.ts");
16
- const RealDate = Date;
17
- function createCustomConsole({ rpc, testPath, printConsoleTrace }) {
18
- const getConsoleTrace = ()=>{
19
- const limit = Error.stackTraceLimit;
20
- Error.stackTraceLimit = 4;
21
- const stack = new Error('STACK_TRACE').stack;
22
- const trace = stack?.split('\n').slice(4).join('\n');
23
- Error.stackTraceLimit = limit;
24
- return trace;
25
- };
26
- class CustomConsole extends Console {
27
- _counters = {};
28
- _timers = {};
29
- _groupDepth = 0;
30
- Console = Console;
31
- getPrettyName(type) {
32
- switch(type){
33
- case 'error':
34
- return utils.yW.red(type);
35
- case 'warn':
36
- return utils.yW.yellow(type);
37
- case 'info':
38
- return utils.yW.cyan(type);
39
- default:
40
- return utils.yW.gray(type);
41
- }
42
- }
43
- _log(name, message, type = 'stdout') {
44
- rpc.onConsoleLog({
45
- content: ' '.repeat(this._groupDepth) + message,
46
- name: this.getPrettyName(name),
47
- testPath,
48
- type,
49
- trace: printConsoleTrace ? getConsoleTrace() : void 0
50
- });
51
- }
52
- assert(value, message) {
53
- try {
54
- strict(value, message);
55
- } catch (error) {
56
- if (!(error instanceof AssertionError)) throw error;
57
- this._log('assert', error.toString().replaceAll(/:\n\n.*\n/gs, ''), 'stderr');
58
- }
59
- }
60
- count(label = 'default') {
61
- if (!this._counters[label]) this._counters[label] = 0;
62
- this._log('count', (0, external_node_util_.format)(`${label}: ${++this._counters[label]}`));
63
- }
64
- countReset(label = 'default') {
65
- this._counters[label] = 0;
66
- }
67
- debug(firstArg, ...args) {
68
- this._log('debug', (0, external_node_util_.format)(firstArg, ...args));
69
- }
70
- dir(firstArg, options = {}) {
71
- const representation = (0, external_node_util_.inspect)(firstArg, options);
72
- this._log('dir', (0, external_node_util_.formatWithOptions)(options, representation));
73
- }
74
- dirxml(firstArg, ...args) {
75
- this._log('dirxml', (0, external_node_util_.format)(firstArg, ...args));
76
- }
77
- error(firstArg, ...args) {
78
- this._log('error', (0, external_node_util_.format)(firstArg, ...args), 'stderr');
79
- }
80
- group(title, ...args) {
81
- this._groupDepth++;
82
- if (null != title || args.length > 0) this._log('group', utils.yW.bold((0, external_node_util_.format)(title, ...args)));
83
- }
84
- groupCollapsed(title, ...args) {
85
- this._groupDepth++;
86
- if (null != title || args.length > 0) this._log('groupCollapsed', utils.yW.bold((0, external_node_util_.format)(title, ...args)));
87
- }
88
- groupEnd() {
89
- if (this._groupDepth > 0) this._groupDepth--;
90
- }
91
- info(firstArg, ...args) {
92
- this._log('info', (0, external_node_util_.format)(firstArg, ...args));
93
- }
94
- log(firstArg, ...args) {
95
- this._log('log', (0, external_node_util_.format)(firstArg, ...args));
96
- }
97
- time(label = 'default') {
98
- if (null != this._timers[label]) return;
99
- this._timers[label] = new RealDate();
100
- }
101
- timeEnd(label = 'default') {
102
- const startTime = this._timers[label];
103
- if (null != startTime) {
104
- const endTime = RealDate.now();
105
- const time = endTime - startTime.getTime();
106
- this._log('time', (0, external_node_util_.format)(`${label}: ${(0, utils.kV)(time)}`));
107
- delete this._timers[label];
108
- }
109
- }
110
- timeLog(label = 'default', ...data) {
111
- const startTime = this._timers[label];
112
- if (null != startTime) {
113
- const endTime = new RealDate();
114
- const time = endTime.getTime() - startTime.getTime();
115
- this._log('time', (0, external_node_util_.format)(`${label}: ${(0, utils.kV)(time)}`, ...data));
116
- }
117
- }
118
- warn(firstArg, ...args) {
119
- this._log('warn', (0, external_node_util_.format)(firstArg, ...args), 'stderr');
120
- }
121
- getBuffer() {}
122
- }
123
- return new CustomConsole(process.stdout, process.stderr);
124
- }
125
- }
126
- };
package/dist/0~603.js DELETED
@@ -1,50 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- export const __webpack_id__ = "603";
4
- export const __webpack_ids__ = [
5
- "603"
6
- ];
7
- export const __webpack_modules__ = {
8
- "./src/coverage/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
- __webpack_require__.d(__webpack_exports__, {
10
- e: ()=>createCoverageProvider,
11
- loadCoverageProvider: ()=>loadCoverageProvider
12
- });
13
- var node_module__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:module");
14
- var node_url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:url");
15
- var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/utils/index.ts");
16
- const CoverageProviderMap = {
17
- istanbul: '@rstest/coverage-istanbul'
18
- };
19
- const loadCoverageProvider = async (options, root)=>{
20
- const rootPath = (0, node_url__WEBPACK_IMPORTED_MODULE_1__.pathToFileURL)(root).toString();
21
- const moduleName = CoverageProviderMap[options.provider || 'istanbul'];
22
- if (!moduleName) throw new Error(`Unknown coverage provider: ${options.provider}`);
23
- try {
24
- const require = (0, node_module__WEBPACK_IMPORTED_MODULE_0__.createRequire)(rootPath);
25
- const modulePath = require.resolve(moduleName, {
26
- paths: [
27
- rootPath
28
- ]
29
- });
30
- const { pluginCoverage, CoverageProvider } = await import((0, node_url__WEBPACK_IMPORTED_MODULE_1__.pathToFileURL)(modulePath).toString());
31
- return {
32
- pluginCoverage,
33
- CoverageProvider
34
- };
35
- } catch {
36
- const error = new Error(`Failed to load coverage provider module: ${_utils__WEBPACK_IMPORTED_MODULE_2__.yW.cyan(moduleName)} in ${_utils__WEBPACK_IMPORTED_MODULE_2__.yW.underline(root)}, please make sure it is installed.\n`);
37
- error.stack = '';
38
- throw error;
39
- }
40
- };
41
- async function createCoverageProvider(options, root) {
42
- if (!options.enabled) return null;
43
- if (!options.provider || CoverageProviderMap[options.provider]) {
44
- const { CoverageProvider } = await loadCoverageProvider(options, root);
45
- return new CoverageProvider(options);
46
- }
47
- throw new Error(`Unknown coverage provider: ${options.provider}`);
48
- }
49
- }
50
- };