@empiricalrun/test-run 0.10.8 → 0.11.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/CHANGELOG.md +12 -0
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/dashboard.js +7 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/lib/cmd.js +1 -1
- package/dist/utils/config.d.ts +1 -9
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +42 -5
- package/eslint.config.mjs +16 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @empiricalrun/test-run
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- cdc0995: feat: introduce env vars for the test run
|
|
8
|
+
|
|
9
|
+
## 0.10.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 450b79a: feat: show resolved projects for environments in cli
|
|
14
|
+
|
|
3
15
|
## 0.10.8
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/dashboard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG7C,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAIF,eAAO,MAAM,wBAAwB,GACnC,aAAa,MAAM,EACnB,iBAAiB,MAAM,KACtB,OAAO,CAAC;IACT,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;CACd,CAwDA,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAAa,OAAO,CACxD,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG7C,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAIF,eAAO,MAAM,wBAAwB,GACnC,aAAa,MAAM,EACnB,iBAAiB,MAAM,KACtB,OAAO,CAAC;IACT,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;CACd,CAwDA,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAAa,OAAO,CACxD,mBAAmB,EAAE,CAkDtB,CAAC"}
|
package/dist/dashboard.js
CHANGED
|
@@ -47,9 +47,14 @@ const fetchEnvironmentVariables = async () => {
|
|
|
47
47
|
if (!process.env.EMPIRICALRUN_API_KEY) {
|
|
48
48
|
return [];
|
|
49
49
|
}
|
|
50
|
+
const testRunId = process.env.TEST_RUN_GITHUB_ACTION_ID;
|
|
51
|
+
if (!testRunId) {
|
|
52
|
+
console.log("No test run ID found, skipping environment variables fetch");
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
50
55
|
try {
|
|
51
56
|
const data = await (0, async_retry_1.default)(async () => {
|
|
52
|
-
const envVarsResp = await fetch(`${DOMAIN}/api/environment-variables`, {
|
|
57
|
+
const envVarsResp = await fetch(`${DOMAIN}/api/test-runs/${testRunId}/environment-variables`, {
|
|
53
58
|
method: "GET",
|
|
54
59
|
headers: {
|
|
55
60
|
"Content-Type": "application/json",
|
|
@@ -71,7 +76,7 @@ const fetchEnvironmentVariables = async () => {
|
|
|
71
76
|
});
|
|
72
77
|
return data && data.data ? data.data.environment_variables : [];
|
|
73
78
|
}
|
|
74
|
-
catch
|
|
79
|
+
catch {
|
|
75
80
|
return [];
|
|
76
81
|
}
|
|
77
82
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { runSpecificTestsCmd } from "./lib/run-specific-test";
|
|
|
4
4
|
import { Platform, TestCase } from "./types";
|
|
5
5
|
import { getProjectsFromPlaywrightConfig } from "./utils/config";
|
|
6
6
|
export { getProjectsFromPlaywrightConfig, Platform, runSpecificTestsCmd, spawnCmd, };
|
|
7
|
+
export { filterArrayByGlobMatchersSet, generateProjectFilters } from "./utils";
|
|
7
8
|
export declare function runSingleTest({ testName, suites, filePath, projects, envOverrides, repoDir, }: {
|
|
8
9
|
testName: string;
|
|
9
10
|
suites: string[];
|
|
@@ -15,7 +16,7 @@ export declare function runSingleTest({ testName, suites, filePath, projects, en
|
|
|
15
16
|
hasTestPassed: boolean;
|
|
16
17
|
summaryJson: PlaywrightJSONReport;
|
|
17
18
|
}>;
|
|
18
|
-
export declare function
|
|
19
|
+
export declare function listProjectsAndTests(repoDir: string): Promise<{
|
|
19
20
|
projects: string[];
|
|
20
21
|
projectsToTestCases: Record<string, TestCase[]>;
|
|
21
22
|
}>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAI/E,OAAO,EAAkB,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,QAA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AM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;CACjD,CAAC,CAaD"}
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,9 @@ 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.spawnCmd = exports.runSpecificTestsCmd = exports.Platform = exports.getProjectsFromPlaywrightConfig = void 0;
|
|
6
|
+
exports.generateProjectFilters = exports.filterArrayByGlobMatchersSet = exports.spawnCmd = exports.runSpecificTestsCmd = exports.Platform = exports.getProjectsFromPlaywrightConfig = void 0;
|
|
7
7
|
exports.runSingleTest = runSingleTest;
|
|
8
|
-
exports.
|
|
8
|
+
exports.listProjectsAndTests = listProjectsAndTests;
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const cmd_1 = require("./lib/cmd");
|
|
@@ -21,6 +21,9 @@ Object.defineProperty(exports, "getProjectsFromPlaywrightConfig", { enumerable:
|
|
|
21
21
|
// For test-run package, the library entrypoint, we only support web platform
|
|
22
22
|
// The bin entrypoint has support for mobile also
|
|
23
23
|
const supportedPlatform = types_1.Platform.WEB;
|
|
24
|
+
var utils_2 = require("./utils");
|
|
25
|
+
Object.defineProperty(exports, "filterArrayByGlobMatchersSet", { enumerable: true, get: function () { return utils_2.filterArrayByGlobMatchersSet; } });
|
|
26
|
+
Object.defineProperty(exports, "generateProjectFilters", { enumerable: true, get: function () { return utils_2.generateProjectFilters; } });
|
|
24
27
|
function getSummaryJsonPath(repoDir) {
|
|
25
28
|
const pathForPlaywright147 = path_1.default.join(repoDir, "playwright-report", "summary.json");
|
|
26
29
|
const pathForOtherPlaywrightVersions = path_1.default.join(repoDir, "summary.json");
|
|
@@ -46,7 +49,7 @@ async function runSingleTest({ testName, suites, filePath, projects, envOverride
|
|
|
46
49
|
summaryJson,
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
|
-
async function
|
|
52
|
+
async function listProjectsAndTests(repoDir) {
|
|
50
53
|
const testRunner = (0, utils_1.getTestRunner)(types_1.Platform.WEB);
|
|
51
54
|
const args = [testRunner, "test", "--list"];
|
|
52
55
|
const { output, code } = await (0, cmd_1.spawnCmd)("npx", args, {
|
package/dist/lib/cmd.js
CHANGED
package/dist/utils/config.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
+
import { PlaywrightProject } from "@empiricalrun/shared-types";
|
|
1
2
|
import { Platform } from "../types";
|
|
2
|
-
type PlaywrightProject = {
|
|
3
|
-
name: string;
|
|
4
|
-
use: any;
|
|
5
|
-
testMatch: string[] | string | undefined;
|
|
6
|
-
testIgnore: string[] | string | undefined;
|
|
7
|
-
testDir: string | undefined;
|
|
8
|
-
teardown: string | undefined;
|
|
9
|
-
};
|
|
10
3
|
export declare function getProjectsFromPlaywrightConfig(platform: Platform, repoDir: string): Promise<PlaywrightProject[]>;
|
|
11
|
-
export {};
|
|
12
4
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAK/D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAyE9B"}
|
package/dist/utils/config.js
CHANGED
|
@@ -14,10 +14,35 @@ async function getProjectsFromPlaywrightConfig(platform, repoDir) {
|
|
|
14
14
|
const configPath = path_1.default.join(repoDir, configName);
|
|
15
15
|
const tmpScriptPath = path_1.default.join(repoDir, "temp-extract-projects.js");
|
|
16
16
|
fs_1.default.writeFileSync(tmpScriptPath, `
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
// Custom serializer that handles regex objects and functions
|
|
18
|
+
function serializeWithSpecialTypes(obj) {
|
|
19
|
+
return JSON.stringify(obj, (key, value) => {
|
|
20
|
+
if (value instanceof RegExp) {
|
|
21
|
+
return {
|
|
22
|
+
__regex: true,
|
|
23
|
+
source: value.source,
|
|
24
|
+
flags: value.flags
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (typeof value === 'function') {
|
|
28
|
+
return {
|
|
29
|
+
__function: true,
|
|
30
|
+
source: value.toString()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
// Import the config directly with the full path
|
|
39
|
+
const configModule = require('${configPath.replace(/\\/g, "\\\\")}');
|
|
40
|
+
const projects = configModule.default?.projects || configModule.projects || [];
|
|
41
|
+
console.log(serializeWithSpecialTypes(projects));
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('Error loading config:', error.message);
|
|
44
|
+
console.log('[]'); // Return empty array on error
|
|
45
|
+
}
|
|
21
46
|
`);
|
|
22
47
|
const result = (0, child_process_1.execSync)(`npx -y ts-node@latest "${tmpScriptPath}"`, {
|
|
23
48
|
encoding: "utf8",
|
|
@@ -29,7 +54,19 @@ async function getProjectsFromPlaywrightConfig(platform, repoDir) {
|
|
|
29
54
|
cwd: repoDir,
|
|
30
55
|
});
|
|
31
56
|
fs_1.default.unlinkSync(tmpScriptPath);
|
|
32
|
-
|
|
57
|
+
// Custom deserializer that reconstructs regex objects
|
|
58
|
+
const projects = JSON.parse(result, (key, value) => {
|
|
59
|
+
if (value && typeof value === "object") {
|
|
60
|
+
if (value.__regex) {
|
|
61
|
+
return new RegExp(value.source, value.flags);
|
|
62
|
+
}
|
|
63
|
+
if (value.__function) {
|
|
64
|
+
// Note: Functions can't be fully reconstructed, but we preserve the source
|
|
65
|
+
return value.source;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
});
|
|
33
70
|
return projects;
|
|
34
71
|
}
|
|
35
72
|
catch (error) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import libraryConfig from "../eslint-config/library.mjs";
|
|
2
|
+
import tsParser from "@typescript-eslint/parser";
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
...libraryConfig,
|
|
6
|
+
{
|
|
7
|
+
files: ["src/**/*.ts", "src/**/*.tsx"],
|
|
8
|
+
languageOptions: {
|
|
9
|
+
parser: tsParser,
|
|
10
|
+
parserOptions: {
|
|
11
|
+
project: "./tsconfig.lint.json",
|
|
12
|
+
tsconfigRootDir: import.meta.dirname,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-run",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"@types/console-log-level": "^1.4.5",
|
|
28
28
|
"@types/node": "^22.5.5",
|
|
29
29
|
"@playwright/test": "1.53.2",
|
|
30
|
-
"memfs": "^4.17.1"
|
|
30
|
+
"memfs": "^4.17.1",
|
|
31
|
+
"@empiricalrun/shared-types": "0.10.0"
|
|
31
32
|
},
|
|
32
33
|
"scripts": {
|
|
33
34
|
"dev": "tsc --build --watch",
|