@empiricalrun/test-run 0.9.0 → 0.9.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/CHANGELOG.md +13 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -1
- package/dist/lib/cmd.d.ts +4 -3
- package/dist/lib/cmd.d.ts.map +1 -1
- package/dist/lib/cmd.js +6 -3
- package/dist/lib/run-all-tests.d.ts.map +1 -1
- package/dist/lib/run-all-tests.js +4 -0
- package/dist/parser/index.d.ts +6 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +42 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @empiricalrun/test-run
|
|
2
2
|
|
|
3
|
+
## 0.9.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d71508f: chore: set playwright runs to headed based on env key
|
|
8
|
+
- fca6729: feat: implement TypeScript compiler execution and error handling in strReplaceEditor
|
|
9
|
+
|
|
10
|
+
## 0.9.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 24d672a: feat: use playwright --list to get project names
|
|
15
|
+
|
|
3
16
|
## 0.9.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { spawnCmd } from "./lib/cmd";
|
|
1
2
|
import { runSpecificTestsCmd } from "./lib/run-specific-test";
|
|
2
|
-
|
|
3
|
+
import { TestCase } from "./types";
|
|
4
|
+
export { runSpecificTestsCmd, spawnCmd };
|
|
3
5
|
export declare function runSingleTest({ testName, suites, fileName, projects, envOverrides, }: {
|
|
4
6
|
testName: string;
|
|
5
7
|
suites: string[];
|
|
@@ -10,4 +12,8 @@ export declare function runSingleTest({ testName, suites, fileName, projects, en
|
|
|
10
12
|
hasTestPassed: boolean;
|
|
11
13
|
summaryJson: any;
|
|
12
14
|
}>;
|
|
15
|
+
export declare function getAllPlaywrightProjects(repoDir: string): Promise<{
|
|
16
|
+
projects: string[];
|
|
17
|
+
projectsToTestCases: Record<string, TestCase[]>;
|
|
18
|
+
}>;
|
|
13
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAY,QAAQ,EAAE,MAAM,SAAS,CAAC;AAO7C,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC;AAEzC,wBAAsB,aAAa,CAAC,EAClC,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;;;GAqBA;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACvE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;CACjD,CAAC,CAaD"}
|
package/dist/index.js
CHANGED
|
@@ -3,14 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.runSpecificTestsCmd = void 0;
|
|
6
|
+
exports.spawnCmd = exports.runSpecificTestsCmd = void 0;
|
|
7
7
|
exports.runSingleTest = runSingleTest;
|
|
8
|
+
exports.getAllPlaywrightProjects = getAllPlaywrightProjects;
|
|
8
9
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
10
11
|
const cmd_1 = require("./lib/cmd");
|
|
12
|
+
Object.defineProperty(exports, "spawnCmd", { enumerable: true, get: function () { return cmd_1.spawnCmd; } });
|
|
11
13
|
const run_specific_test_1 = require("./lib/run-specific-test");
|
|
12
14
|
Object.defineProperty(exports, "runSpecificTestsCmd", { enumerable: true, get: function () { return run_specific_test_1.runSpecificTestsCmd; } });
|
|
15
|
+
const parser_1 = require("./parser");
|
|
13
16
|
const types_1 = require("./types");
|
|
17
|
+
const utils_1 = require("./utils");
|
|
14
18
|
// For test-run package, the library entrypoint, we only support web platform
|
|
15
19
|
// The bin entrypoint has support for mobile also
|
|
16
20
|
const supportedPlatform = types_1.Platform.WEB;
|
|
@@ -32,3 +36,17 @@ async function runSingleTest({ testName, suites, fileName, projects, envOverride
|
|
|
32
36
|
summaryJson,
|
|
33
37
|
};
|
|
34
38
|
}
|
|
39
|
+
async function getAllPlaywrightProjects(repoDir) {
|
|
40
|
+
const testRunner = (0, utils_1.getTestRunner)(types_1.Platform.WEB);
|
|
41
|
+
const env = Object({ ...process.env });
|
|
42
|
+
const args = [testRunner, "test", "--list"];
|
|
43
|
+
const { output, code } = await (0, cmd_1.spawnCmd)("npx", args, {
|
|
44
|
+
env,
|
|
45
|
+
cwd: repoDir,
|
|
46
|
+
captureOutput: true,
|
|
47
|
+
});
|
|
48
|
+
if (!output) {
|
|
49
|
+
throw new Error(`Failed to run list command; exit code: ${code}`);
|
|
50
|
+
}
|
|
51
|
+
return (0, parser_1.parseTestListOutput)(output);
|
|
52
|
+
}
|
package/dist/lib/cmd.d.ts
CHANGED
|
@@ -6,12 +6,13 @@ export declare function getCommandFromString(command: string): {
|
|
|
6
6
|
export declare function runTestsForCmd({ command, args, env }: CommandToRun): Promise<{
|
|
7
7
|
hasTestPassed: boolean;
|
|
8
8
|
}>;
|
|
9
|
-
export declare function spawnCmd(command: string, args: string[], options
|
|
9
|
+
export declare function spawnCmd(command: string, args: string[], options?: {
|
|
10
10
|
env?: Record<string, string>;
|
|
11
11
|
cwd?: string;
|
|
12
12
|
captureOutput?: boolean;
|
|
13
|
-
|
|
13
|
+
throwOnError?: boolean;
|
|
14
|
+
}): Promise<{
|
|
14
15
|
code: number;
|
|
15
|
-
output
|
|
16
|
+
output?: string;
|
|
16
17
|
}>;
|
|
17
18
|
//# sourceMappingURL=cmd.d.ts.map
|
package/dist/lib/cmd.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmd.d.ts","sourceRoot":"","sources":["../../src/lib/cmd.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAeA;AAED,wBAAsB,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,YAAY;;GASxE;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,
|
|
1
|
+
{"version":3,"file":"cmd.d.ts","sourceRoot":"","sources":["../../src/lib/cmd.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAeA;AAED,wBAAsB,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,YAAY;;GASxE;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IACP,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;CAIxB,GACA,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA6C5C"}
|
package/dist/lib/cmd.js
CHANGED
|
@@ -29,7 +29,10 @@ async function runTestsForCmd({ command, args, env }) {
|
|
|
29
29
|
}
|
|
30
30
|
return { hasTestPassed };
|
|
31
31
|
}
|
|
32
|
-
async function spawnCmd(command, args, options
|
|
32
|
+
async function spawnCmd(command, args, options = {
|
|
33
|
+
captureOutput: false,
|
|
34
|
+
throwOnError: true,
|
|
35
|
+
}) {
|
|
33
36
|
let output = options.captureOutput ? "" : undefined;
|
|
34
37
|
let errorLogs = [];
|
|
35
38
|
return new Promise((resolveFunc, rejectFunc) => {
|
|
@@ -61,12 +64,12 @@ async function spawnCmd(command, args, options) {
|
|
|
61
64
|
p.on("exit", (code) => {
|
|
62
65
|
// Clean up signal handlers when the process exits
|
|
63
66
|
cleanupSignalHandlers();
|
|
64
|
-
if (code != 0) {
|
|
67
|
+
if (code != 0 && options.throwOnError) {
|
|
65
68
|
// assuming last log is the error message before exiting
|
|
66
69
|
rejectFunc(errorLogs.slice(-3).join("\n"));
|
|
67
70
|
}
|
|
68
71
|
else {
|
|
69
|
-
resolveFunc(
|
|
72
|
+
resolveFunc({ code: code, output: output });
|
|
70
73
|
}
|
|
71
74
|
});
|
|
72
75
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-all-tests.d.ts","sourceRoot":"","sources":["../../src/lib/run-all-tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAQ5D,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,eAAe,EACf,cAAc,EACd,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"run-all-tests.d.ts","sourceRoot":"","sources":["../../src/lib/run-all-tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAQ5D,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,eAAe,EACf,cAAc,EACd,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,GAAG,YAAY,CAyBf"}
|
|
@@ -16,6 +16,10 @@ function runAllTestsCmd({ projects, passthroughArgs, patternsToGrep, filesFilter
|
|
|
16
16
|
.join(" ");
|
|
17
17
|
let args = ` ${filesFilter || ""} ${grepArgs} ${projectsArg} ${passthroughArgs || ""}`;
|
|
18
18
|
const env = Object.assign({ ...process.env, PW_TEST_HTML_REPORT_OPEN: "never" }, envOverrides);
|
|
19
|
+
if (process.env.RUN_PLAYWRIGHT_HEADED &&
|
|
20
|
+
process.env.RUN_PLAYWRIGHT_HEADED === "true") {
|
|
21
|
+
args = `${args} --headed`;
|
|
22
|
+
}
|
|
19
23
|
const testRunCmd = normalizeSpaces(`npx ${testRunner} test ${args}`);
|
|
20
24
|
return {
|
|
21
25
|
...(0, cmd_1.getCommandFromString)(testRunCmd),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG;IACnD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;CACjD,CA0CA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTestListOutput = parseTestListOutput;
|
|
4
|
+
function parseTestListOutput(output) {
|
|
5
|
+
// Parse the output to extract test information
|
|
6
|
+
// Example format: "[chromium] › home.spec.ts:9:9 › describe 1 › describe 2 › has title"
|
|
7
|
+
let projectsToTestCases = {};
|
|
8
|
+
let projects = [];
|
|
9
|
+
output
|
|
10
|
+
.split("\n")
|
|
11
|
+
.filter((line) => line.trim() && line.trim().startsWith("[") && line.includes(".ts:"))
|
|
12
|
+
.forEach((line) => {
|
|
13
|
+
// Extract project, file, line, and test name with suites
|
|
14
|
+
const match = line.match(/\[(.*?)\]\s+›\s+(.*?):(\d+):\d+\s+›\s+(.*)/);
|
|
15
|
+
if (!match || !match[1] || !match[2] || !match[3] || !match[4]) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const project = match[1];
|
|
19
|
+
if (!projects.includes(project)) {
|
|
20
|
+
projects.push(project);
|
|
21
|
+
projectsToTestCases[project] = [];
|
|
22
|
+
}
|
|
23
|
+
const file = match[2];
|
|
24
|
+
const fullTestName = match[4];
|
|
25
|
+
const parts = fullTestName.split("›").map((p) => p.trim());
|
|
26
|
+
if (parts.length === 0) {
|
|
27
|
+
throw new Error(`Invalid test name: ${fullTestName}`);
|
|
28
|
+
}
|
|
29
|
+
const name = parts[parts.length - 1];
|
|
30
|
+
if (!name) {
|
|
31
|
+
throw new Error(`Invalid test name: ${fullTestName}`);
|
|
32
|
+
}
|
|
33
|
+
const describeBlockNames = parts.length > 1 ? parts.slice(0, -1) : undefined;
|
|
34
|
+
const testCase = {
|
|
35
|
+
name,
|
|
36
|
+
filePath: file,
|
|
37
|
+
suites: describeBlockNames,
|
|
38
|
+
};
|
|
39
|
+
projectsToTestCases[project].push(testCase);
|
|
40
|
+
});
|
|
41
|
+
return { projects, projectsToTestCases };
|
|
42
|
+
}
|
package/package.json
CHANGED
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/dashboard.ts","./src/index.ts","./src/bin/index.ts","./src/lib/cmd.ts","./src/lib/run-all-tests.ts","./src/lib/run-specific-test.ts","./src/lib/memfs/read-hello-world.ts","./src/types/index.ts","./src/utils/config-parser.ts","./src/utils/config.ts","./src/utils/index.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["./src/dashboard.ts","./src/index.ts","./src/bin/index.ts","./src/lib/cmd.ts","./src/lib/run-all-tests.ts","./src/lib/run-specific-test.ts","./src/lib/memfs/read-hello-world.ts","./src/parser/index.ts","./src/types/index.ts","./src/utils/config-parser.ts","./src/utils/config.ts","./src/utils/index.ts"],"version":"5.8.3"}
|