@rspack-debug/test-tools 2.0.0-beta.0 → 2.0.0-beta.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/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './case';
2
2
  export * from './helper';
3
3
  export * from './plugin';
4
+ export * from './reporter';
4
5
  export * from './runner';
5
6
  export * from './test/context';
6
7
  export * from './test/creator';
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./case"), exports);
18
18
  __exportStar(require("./helper"), exports);
19
19
  __exportStar(require("./plugin"), exports);
20
+ __exportStar(require("./reporter"), exports);
20
21
  __exportStar(require("./runner"), exports);
21
22
  __exportStar(require("./test/context"), exports);
22
23
  __exportStar(require("./test/creator"), exports);
@@ -0,0 +1 @@
1
+ export * from './streamed-events-reporter';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./streamed-events-reporter"), exports);
@@ -0,0 +1,34 @@
1
+ import type { Reporter, TestCaseInfo, TestFileInfo, TestResult, TestSuiteInfo } from '@rstest/core';
2
+ /**
3
+ * Stream Rstest events to a file in real-time for inspecting how tests are executed.
4
+ *
5
+ * Event format: `<context> | <event_type> | <timestamp> [| <additional_fields>]`
6
+ *
7
+ * @example
8
+ * __GLOBAL__ | TEST_RUN_START | 2025-01-15T10:30:00.123Z
9
+ * tests/unit/example.test.ts | FILE_START | 2025-01-15T10:30:00.456Z
10
+ * tests/unit/example.test.ts | FILE_READY | 2025-01-15T10:30:00.789Z
11
+ * tests/unit/example.test.ts > Suite Name | SUITE_START | 2025-01-15T10:30:01.000Z
12
+ * tests/unit/example.test.ts > Suite Name > nested describe | SUITE_START | 2025-01-15T10:30:01.100Z
13
+ * tests/unit/example.test.ts > Suite Name > nested describe > should work | TEST_START | 2025-01-15T10:30:01.200Z
14
+ * tests/unit/example.test.ts > Suite Name > nested describe > should work | TEST_END | 2025-01-15T10:30:01.350Z | passed | 150ms
15
+ * tests/unit/example.test.ts > Suite Name > nested describe | SUITE_END | 2025-01-15T10:30:01.400Z | passed | 300ms
16
+ * tests/unit/example.test.ts > Suite Name | SUITE_END | 2025-01-15T10:30:01.500Z | passed | 500ms
17
+ * __GLOBAL__ | TEST_RUN_END | 2025-01-15T10:30:02.000Z
18
+ * */
19
+ export declare class StreamedEventReporter implements Reporter {
20
+ private stream;
21
+ private outputPath;
22
+ constructor(outputPath?: string);
23
+ private write;
24
+ private formatTimestamp;
25
+ onTestRunStart(): void;
26
+ onTestFileStart(file: TestFileInfo): void;
27
+ onTestFileReady(file: TestFileInfo): void;
28
+ onTestSuiteStart(suite: TestSuiteInfo): void;
29
+ onTestSuiteResult(result: TestResult): void;
30
+ onTestCaseStart(test: TestCaseInfo): void;
31
+ onTestCaseResult(result: TestResult): void;
32
+ onTestRunEnd(): Promise<void>;
33
+ onExit(): void;
34
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.StreamedEventReporter = void 0;
37
+ const fs = __importStar(require("node:fs"));
38
+ const path = __importStar(require("node:path"));
39
+ /**
40
+ * Stream Rstest events to a file in real-time for inspecting how tests are executed.
41
+ *
42
+ * Event format: `<context> | <event_type> | <timestamp> [| <additional_fields>]`
43
+ *
44
+ * @example
45
+ * __GLOBAL__ | TEST_RUN_START | 2025-01-15T10:30:00.123Z
46
+ * tests/unit/example.test.ts | FILE_START | 2025-01-15T10:30:00.456Z
47
+ * tests/unit/example.test.ts | FILE_READY | 2025-01-15T10:30:00.789Z
48
+ * tests/unit/example.test.ts > Suite Name | SUITE_START | 2025-01-15T10:30:01.000Z
49
+ * tests/unit/example.test.ts > Suite Name > nested describe | SUITE_START | 2025-01-15T10:30:01.100Z
50
+ * tests/unit/example.test.ts > Suite Name > nested describe > should work | TEST_START | 2025-01-15T10:30:01.200Z
51
+ * tests/unit/example.test.ts > Suite Name > nested describe > should work | TEST_END | 2025-01-15T10:30:01.350Z | passed | 150ms
52
+ * tests/unit/example.test.ts > Suite Name > nested describe | SUITE_END | 2025-01-15T10:30:01.400Z | passed | 300ms
53
+ * tests/unit/example.test.ts > Suite Name | SUITE_END | 2025-01-15T10:30:01.500Z | passed | 500ms
54
+ * __GLOBAL__ | TEST_RUN_END | 2025-01-15T10:30:02.000Z
55
+ * */
56
+ class StreamedEventReporter {
57
+ constructor(outputPath) {
58
+ this.outputPath =
59
+ outputPath || path.join(process.cwd(), 'rstest-streamed-report.txt');
60
+ const dir = path.dirname(this.outputPath);
61
+ if (!fs.existsSync(dir)) {
62
+ fs.mkdirSync(dir, { recursive: true });
63
+ }
64
+ this.stream = fs.createWriteStream(this.outputPath, { flags: 'w' });
65
+ }
66
+ write(message) {
67
+ this.stream.write(`${message}\n`);
68
+ }
69
+ formatTimestamp() {
70
+ return new Date().toISOString();
71
+ }
72
+ onTestRunStart() {
73
+ this.write(`__GLOBAL__ | TEST_RUN_START | ${this.formatTimestamp()}`);
74
+ }
75
+ onTestFileStart(file) {
76
+ this.write(`${file.testPath} | FILE_START | ${this.formatTimestamp()}`);
77
+ }
78
+ onTestFileReady(file) {
79
+ this.write(`${file.testPath} | FILE_READY | ${this.formatTimestamp()}`);
80
+ }
81
+ onTestSuiteStart(suite) {
82
+ const suitePath = suite.parentNames
83
+ ? `${suite.parentNames.join(' > ')} > ${suite.name}`
84
+ : suite.name;
85
+ this.write(`${suite.testPath} > ${suitePath} | SUITE_START | ${this.formatTimestamp()}`);
86
+ }
87
+ onTestSuiteResult(result) {
88
+ const suitePath = result.parentNames
89
+ ? `${result.parentNames.join(' > ')} > ${result.name}`
90
+ : result.name;
91
+ this.write(`${result.testPath} > ${suitePath} | SUITE_END | ${this.formatTimestamp()} | ${result.status} | ${result.duration}ms`);
92
+ }
93
+ onTestCaseStart(test) {
94
+ const testPath = test.parentNames
95
+ ? `${test.parentNames.join(' > ')} > ${test.name}`
96
+ : test.name;
97
+ this.write(`${test.testPath} > ${testPath} | TEST_START | ${this.formatTimestamp()}`);
98
+ }
99
+ onTestCaseResult(result) {
100
+ const testPath = result.parentNames
101
+ ? `${result.parentNames.join(' > ')} > ${result.name}`
102
+ : result.name;
103
+ this.write(`${result.testPath} > ${testPath} | TEST_END | ${this.formatTimestamp()} | ${result.status} | ${result.duration}ms`);
104
+ if (result.errors && result.errors.length > 0) {
105
+ this.write(`${result.testPath} > ${testPath} | TEST_ERROR | ${this.formatTimestamp()} | ${result.errors[0].message}`);
106
+ }
107
+ }
108
+ async onTestRunEnd() {
109
+ this.write(`__GLOBAL__ | TEST_RUN_END | ${this.formatTimestamp()}`);
110
+ return new Promise((resolve) => {
111
+ this.stream.end(() => {
112
+ resolve();
113
+ });
114
+ });
115
+ }
116
+ onExit() {
117
+ this.stream.end();
118
+ }
119
+ }
120
+ exports.StreamedEventReporter = StreamedEventReporter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-debug/test-tools",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.2",
4
4
  "license": "MIT",
5
5
  "description": "Test tools for rspack",
6
6
  "main": "dist/index.js",
@@ -15,7 +15,9 @@
15
15
  "./package.json": "./package.json",
16
16
  "./helper/*": "./dist/helper/*.js",
17
17
  "./helper/legacy/*": "./dist/helper/legacy/*.js",
18
- "./helper/util/*": "./dist/helper/util/*.js"
18
+ "./helper/util/*": "./dist/helper/util/*.js",
19
+ "./reporter": "./dist/reporter/index.js",
20
+ "./reporter/*": "./dist/reporter/*.js"
19
21
  },
20
22
  "files": [
21
23
  "client",
@@ -35,10 +37,10 @@
35
37
  "directory": "packages/rspack-test-tools"
36
38
  },
37
39
  "dependencies": {
38
- "@babel/generator": "7.28.6",
39
- "@babel/parser": "7.28.6",
40
- "@babel/traverse": "7.28.6",
41
- "@babel/types": "7.28.6",
40
+ "@babel/generator": "7.29.1",
41
+ "@babel/parser": "7.29.0",
42
+ "@babel/traverse": "7.29.0",
43
+ "@babel/types": "7.29.0",
42
44
  "cross-env": "^10.1.0",
43
45
  "filenamify": "4.3.0",
44
46
  "fs-extra": "^11.3.3",
@@ -65,7 +67,7 @@
65
67
  "@types/jsdom": "^21.1.7",
66
68
  "typescript": "^5.9.3",
67
69
  "wast-loader": "^1.14.1",
68
- "@rspack/core": "npm:@rspack-debug/core@2.0.0-beta.0"
70
+ "@rspack/core": "npm:@rspack-debug/core@2.0.0-beta.2"
69
71
  },
70
72
  "peerDependencies": {
71
73
  "@rspack/core": ">=1.0.0"