@empiricalrun/test-run 0.9.3 → 0.10.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 +17 -0
- package/dist/bin/index.js +17 -4
- package/dist/dashboard.d.ts +9 -0
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/dashboard.js +34 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/lib/cmd.d.ts +1 -1
- package/dist/lib/cmd.d.ts.map +1 -1
- package/dist/lib/cmd.js +2 -2
- package/dist/lib/run-specific-test.d.ts.map +1 -1
- package/dist/lib/run-specific-test.js +8 -2
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +2 -1
- package/dist/utils/index.d.ts +8 -5
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +19 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @empiricalrun/test-run
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0ef2e11: feat(test-run): add environment variables fetching and injection
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 226c361: fix: validate file existence in text edit tools, browser agent and run test tool and update fileName to filePath
|
|
12
|
+
- 8c7e9c6: fix: trim playwright_projects before environment update to ensure glob matching
|
|
13
|
+
|
|
14
|
+
## 0.9.4
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- f926e40: feat: consume repoPath in test run tool
|
|
19
|
+
|
|
3
20
|
## 0.9.3
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/bin/index.js
CHANGED
|
@@ -16,6 +16,7 @@ const config_parser_1 = require("../utils/config-parser");
|
|
|
16
16
|
dotenv_1.default.config({
|
|
17
17
|
path: [".env.local", ".env"],
|
|
18
18
|
});
|
|
19
|
+
const repoDir = process.cwd();
|
|
19
20
|
(async function main() {
|
|
20
21
|
commander_1.program
|
|
21
22
|
.option("-n, --name <test-name>", "Name of the test to run")
|
|
@@ -79,6 +80,16 @@ dotenv_1.default.config({
|
|
|
79
80
|
]
|
|
80
81
|
: undefined);
|
|
81
82
|
const environmentSlug = process.env.TEST_RUN_ENVIRONMENT || "";
|
|
83
|
+
// Fetch environment variables from dashboard
|
|
84
|
+
const environmentVariables = await (0, dashboard_1.fetchEnvironmentVariables)();
|
|
85
|
+
const envOverrides = {};
|
|
86
|
+
// Convert environment variables to key-value pairs for process.env
|
|
87
|
+
environmentVariables.forEach((envVar) => {
|
|
88
|
+
envOverrides[envVar.name] = envVar.value;
|
|
89
|
+
});
|
|
90
|
+
if (Object.keys(envOverrides).length > 0) {
|
|
91
|
+
console.log(`Loaded environment variables: ${Object.keys(envOverrides).join(", ")}`);
|
|
92
|
+
}
|
|
82
93
|
let environmentSpecificProjects = [];
|
|
83
94
|
let platform = types_1.Platform.WEB;
|
|
84
95
|
try {
|
|
@@ -95,10 +106,10 @@ dotenv_1.default.config({
|
|
|
95
106
|
const projectFilters = await (0, utils_1.generateProjectFilters)({
|
|
96
107
|
platform,
|
|
97
108
|
filteringSets: [...options.project, ...environmentSpecificProjects],
|
|
98
|
-
repoDir
|
|
109
|
+
repoDir,
|
|
99
110
|
});
|
|
100
111
|
if (options.skipTeardown) {
|
|
101
|
-
await (0, utils_1.handleTeardownSkipFlag)(directory);
|
|
112
|
+
await (0, utils_1.handleTeardownSkipFlag)(directory, repoDir);
|
|
102
113
|
}
|
|
103
114
|
const hasTestsFilter = tests && tests.length > 0;
|
|
104
115
|
let commandToRun;
|
|
@@ -108,7 +119,8 @@ dotenv_1.default.config({
|
|
|
108
119
|
projects: projectFilters,
|
|
109
120
|
passthroughArgs: pwOptions.join(" "),
|
|
110
121
|
platform,
|
|
111
|
-
|
|
122
|
+
envOverrides,
|
|
123
|
+
repoDir,
|
|
112
124
|
});
|
|
113
125
|
}
|
|
114
126
|
else {
|
|
@@ -116,9 +128,10 @@ dotenv_1.default.config({
|
|
|
116
128
|
projects: projectFilters,
|
|
117
129
|
passthroughArgs: pwOptions.join(" "),
|
|
118
130
|
platform,
|
|
131
|
+
envOverrides,
|
|
119
132
|
});
|
|
120
133
|
}
|
|
121
|
-
const { hasTestPassed } = await (0, cmd_1.runTestsForCmd)(commandToRun);
|
|
134
|
+
const { hasTestPassed } = await (0, cmd_1.runTestsForCmd)(commandToRun, repoDir);
|
|
122
135
|
if (!hasTestPassed) {
|
|
123
136
|
process.exit(1);
|
|
124
137
|
}
|
package/dist/dashboard.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Build, Environment } from "./types";
|
|
2
|
+
export type EnvironmentVariable = {
|
|
3
|
+
id: number;
|
|
4
|
+
project_id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
created_at: string;
|
|
8
|
+
updated_at: string;
|
|
9
|
+
};
|
|
2
10
|
export declare const fetchEnvironmentAndBuild: (projectName: string, environmentSlug: string) => Promise<{
|
|
3
11
|
environment: Environment;
|
|
4
12
|
build: Build;
|
|
5
13
|
}>;
|
|
14
|
+
export declare const fetchEnvironmentVariables: () => Promise<EnvironmentVariable[]>;
|
|
6
15
|
//# sourceMappingURL=dashboard.d.ts.map
|
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;
|
|
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,CAuDA,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAAa,OAAO,CACxD,mBAAmB,EAAE,CA0CtB,CAAC"}
|
package/dist/dashboard.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.fetchEnvironmentAndBuild = void 0;
|
|
6
|
+
exports.fetchEnvironmentVariables = exports.fetchEnvironmentAndBuild = void 0;
|
|
7
7
|
const async_retry_1 = __importDefault(require("async-retry"));
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
const DOMAIN = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
|
|
@@ -42,3 +42,36 @@ const fetchEnvironmentAndBuild = async (projectName, environmentSlug) => {
|
|
|
42
42
|
return data.data;
|
|
43
43
|
};
|
|
44
44
|
exports.fetchEnvironmentAndBuild = fetchEnvironmentAndBuild;
|
|
45
|
+
const fetchEnvironmentVariables = async () => {
|
|
46
|
+
if (!process.env.EMPIRICALRUN_API_KEY) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const data = await (0, async_retry_1.default)(async () => {
|
|
51
|
+
const envVarsResp = await fetch(`${DOMAIN}/api/environment-variables`, {
|
|
52
|
+
method: "GET",
|
|
53
|
+
headers: {
|
|
54
|
+
"Content-Type": "application/json",
|
|
55
|
+
Authorization: `Bearer ${process.env.EMPIRICALRUN_API_KEY}`,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
if (!envVarsResp.ok) {
|
|
59
|
+
if (envVarsResp.status === 400) {
|
|
60
|
+
return { data: { environmentVariables: [] } };
|
|
61
|
+
}
|
|
62
|
+
throw new Error(`HTTP ${envVarsResp.status}: Failed to fetch environment variables`);
|
|
63
|
+
}
|
|
64
|
+
return (await envVarsResp.json());
|
|
65
|
+
}, {
|
|
66
|
+
retries: 3,
|
|
67
|
+
minTimeout: 1000,
|
|
68
|
+
maxTimeout: 60_000,
|
|
69
|
+
factor: 3,
|
|
70
|
+
});
|
|
71
|
+
return data && data.data ? data.data.environmentVariables : [];
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.fetchEnvironmentVariables = fetchEnvironmentVariables;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { spawnCmd } from "./lib/cmd";
|
|
|
2
2
|
import { runSpecificTestsCmd } from "./lib/run-specific-test";
|
|
3
3
|
import { TestCase } from "./types";
|
|
4
4
|
export { runSpecificTestsCmd, spawnCmd };
|
|
5
|
-
export declare function runSingleTest({ testName, suites,
|
|
5
|
+
export declare function runSingleTest({ testName, suites, filePath, projects, envOverrides, repoDir, }: {
|
|
6
6
|
testName: string;
|
|
7
7
|
suites: string[];
|
|
8
|
-
|
|
8
|
+
filePath: string;
|
|
9
9
|
projects: string[];
|
|
10
10
|
envOverrides?: Record<string, string>;
|
|
11
11
|
repoDir: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,mBAA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B,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;CACjD,CAAC,CAaD"}
|
package/dist/index.js
CHANGED
|
@@ -18,9 +18,8 @@ const utils_1 = require("./utils");
|
|
|
18
18
|
// For test-run package, the library entrypoint, we only support web platform
|
|
19
19
|
// The bin entrypoint has support for mobile also
|
|
20
20
|
const supportedPlatform = types_1.Platform.WEB;
|
|
21
|
-
async function runSingleTest({ testName, suites,
|
|
21
|
+
async function runSingleTest({ testName, suites, filePath, projects, envOverrides, repoDir, }) {
|
|
22
22
|
const testDir = "tests";
|
|
23
|
-
const filePath = path_1.default.relative(repoDir, fileName);
|
|
24
23
|
const commandToRun = await (0, run_specific_test_1.runSpecificTestsCmd)({
|
|
25
24
|
tests: [{ name: testName, dir: testDir, filePath, suites }],
|
|
26
25
|
projects,
|
|
@@ -28,7 +27,7 @@ async function runSingleTest({ testName, suites, fileName, projects, envOverride
|
|
|
28
27
|
platform: supportedPlatform,
|
|
29
28
|
repoDir,
|
|
30
29
|
});
|
|
31
|
-
const { hasTestPassed } = await (0, cmd_1.runTestsForCmd)(commandToRun);
|
|
30
|
+
const { hasTestPassed } = await (0, cmd_1.runTestsForCmd)(commandToRun, repoDir);
|
|
32
31
|
const jsonFilePath = path_1.default.join(repoDir, "playwright-report", `summary.json`);
|
|
33
32
|
const jsonFileContents = await promises_1.default.readFile(jsonFilePath, "utf8");
|
|
34
33
|
const summaryJson = JSON.parse(jsonFileContents);
|
package/dist/lib/cmd.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare function getCommandFromString(command: string): {
|
|
|
3
3
|
command: string;
|
|
4
4
|
args: string[];
|
|
5
5
|
};
|
|
6
|
-
export declare function runTestsForCmd({ command, args, env }: CommandToRun): Promise<{
|
|
6
|
+
export declare function runTestsForCmd({ command, args, env }: CommandToRun, cwd: string): Promise<{
|
|
7
7
|
hasTestPassed: boolean;
|
|
8
8
|
}>;
|
|
9
9
|
export declare function spawnCmd(command: string, args: string[], options: {
|
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,
|
|
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,CAClC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,YAAY,EACpC,GAAG,EAAE,MAAM;;GAeZ;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;CACvB,GACA,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA6C5C"}
|
package/dist/lib/cmd.js
CHANGED
|
@@ -18,12 +18,12 @@ function getCommandFromString(command) {
|
|
|
18
18
|
}),
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
async function runTestsForCmd({ command, args, env }) {
|
|
21
|
+
async function runTestsForCmd({ command, args, env }, cwd) {
|
|
22
22
|
console.log(`Running cmd: ${command} with args: ${args}`);
|
|
23
23
|
let hasTestPassed = true;
|
|
24
24
|
try {
|
|
25
25
|
await spawnCmd(command, args, {
|
|
26
|
-
cwd
|
|
26
|
+
cwd,
|
|
27
27
|
envOverrides: env,
|
|
28
28
|
captureOutput: false,
|
|
29
29
|
throwOnError: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-specific-test.d.ts","sourceRoot":"","sources":["../../src/lib/run-specific-test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-specific-test.d.ts","sourceRoot":"","sources":["../../src/lib/run-specific-test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAY5D,wBAAsB,mBAAmB,CAAC,EACxC,KAAU,EACV,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,OAAO,GACR,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,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,YAAY,CAAC,CA0FxB"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.runSpecificTestsCmd = runSpecificTestsCmd;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const utils_1 = require("../utils");
|
|
5
9
|
const run_all_tests_1 = require("./run-all-tests");
|
|
6
10
|
async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, platform, envOverrides, repoDir, }) {
|
|
@@ -12,7 +16,7 @@ async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, plat
|
|
|
12
16
|
for (const testCase of tests) {
|
|
13
17
|
// TODO: Why do we have this getAllFilePaths call?
|
|
14
18
|
// TODO: Can we remove `dir` from the test case entity?
|
|
15
|
-
const files = await (0, utils_1.getAllFilePaths)(testCase.dir, {
|
|
19
|
+
const files = await (0, utils_1.getAllFilePaths)(testCase.dir, repoDir, {
|
|
16
20
|
filePath: testCase.filePath,
|
|
17
21
|
});
|
|
18
22
|
let matchingFilePath = "";
|
|
@@ -21,6 +25,7 @@ async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, plat
|
|
|
21
25
|
filePath: file,
|
|
22
26
|
scenarioName: testCase.name,
|
|
23
27
|
suites: testCase.suites,
|
|
28
|
+
repoDir,
|
|
24
29
|
});
|
|
25
30
|
if (match) {
|
|
26
31
|
matchingFilePath = file;
|
|
@@ -42,8 +47,9 @@ async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, plat
|
|
|
42
47
|
filePath: matchingFilePath,
|
|
43
48
|
scenarioName: testCase.name,
|
|
44
49
|
suites: testCase.suites,
|
|
50
|
+
repoDir,
|
|
45
51
|
});
|
|
46
|
-
const isFileMarkedSerial = await (0, utils_1.hasTopLevelDescribeConfigureWithSerialMode)(matchingFilePath);
|
|
52
|
+
const isFileMarkedSerial = await (0, utils_1.hasTopLevelDescribeConfigureWithSerialMode)(path_1.default.join(repoDir, matchingFilePath));
|
|
47
53
|
if (!isFileMarkedSerial && testCaseNode) {
|
|
48
54
|
const parentDescribe = (0, utils_1.findFirstSerialDescribeBlock)(testCaseNode);
|
|
49
55
|
if (!parentDescribe) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;IACzC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;IACzC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA+B9B"}
|
package/dist/utils/config.js
CHANGED
|
@@ -12,7 +12,7 @@ async function getProjectsFromPlaywrightConfig(platform, repoDir) {
|
|
|
12
12
|
const configName = platform === types_1.Platform.WEB ? "playwright.config.ts" : "appwright.config.ts";
|
|
13
13
|
try {
|
|
14
14
|
const configPath = path_1.default.join(repoDir, configName);
|
|
15
|
-
const tmpScriptPath = path_1.default.
|
|
15
|
+
const tmpScriptPath = path_1.default.join(repoDir, "temp-extract-projects.js");
|
|
16
16
|
fs_1.default.writeFileSync(tmpScriptPath, `
|
|
17
17
|
// Import the config directly with the full path
|
|
18
18
|
const configModule = require('${configPath.replace(/\\/g, "\\\\")}');
|
|
@@ -26,6 +26,7 @@ async function getProjectsFromPlaywrightConfig(platform, repoDir) {
|
|
|
26
26
|
TS_NODE_PROJECT: path_1.default.join(repoDir, "tsconfig.json"),
|
|
27
27
|
NODE_PATH: path_1.default.join(repoDir, "node_modules"),
|
|
28
28
|
},
|
|
29
|
+
cwd: repoDir,
|
|
29
30
|
});
|
|
30
31
|
fs_1.default.unlinkSync(tmpScriptPath);
|
|
31
32
|
const projects = JSON.parse(result);
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { Node, SourceFile } from "ts-morph";
|
|
2
2
|
import { Platform, TestFramework } from "../types";
|
|
3
|
-
export declare function getAllFilePaths(directoryPath
|
|
3
|
+
export declare function getAllFilePaths(directoryPath: string | undefined, repoDir: string, filters?: {
|
|
4
4
|
filePath?: string;
|
|
5
5
|
}): Promise<string[]>;
|
|
6
6
|
export declare const getTestModuleAliasFromSourceFile: (sourceFile: SourceFile) => string;
|
|
7
|
-
export declare function getTestCaseNode({ filePath, scenarioName, suites, }: {
|
|
7
|
+
export declare function getTestCaseNode({ filePath, scenarioName, suites, repoDir, }: {
|
|
8
8
|
filePath: string;
|
|
9
9
|
scenarioName: string;
|
|
10
10
|
suites?: string[];
|
|
11
|
+
repoDir: string;
|
|
11
12
|
}): Promise<{
|
|
12
13
|
testCaseNode: Node | undefined;
|
|
13
14
|
sourceFile: SourceFile;
|
|
14
15
|
}>;
|
|
15
|
-
export declare function hasTestBlock({ filePath, scenarioName, suites, }: {
|
|
16
|
+
export declare function hasTestBlock({ filePath, scenarioName, suites, repoDir, }: {
|
|
16
17
|
filePath: string;
|
|
17
18
|
scenarioName: string;
|
|
18
19
|
suites?: string[];
|
|
20
|
+
repoDir: string;
|
|
19
21
|
}): Promise<boolean>;
|
|
20
22
|
export declare function getDescribeBlockName(node: Node): string | undefined;
|
|
21
23
|
export declare function findFirstSerialDescribeBlock(node: Node | undefined): Node | undefined;
|
|
@@ -40,7 +42,7 @@ export declare function buildRepoName(projectName: string): string;
|
|
|
40
42
|
export declare const pickNameFromPackageJson: () => Promise<string | undefined>;
|
|
41
43
|
export declare const downloadBuild: (buildUrl: string) => Promise<void>;
|
|
42
44
|
export declare const getTestRunner: (platform: Platform) => TestFramework;
|
|
43
|
-
export declare const handleTeardownSkipFlag: (directory: string) => Promise<void>;
|
|
45
|
+
export declare const handleTeardownSkipFlag: (directory: string, repoDir: string) => Promise<void>;
|
|
44
46
|
/**
|
|
45
47
|
* function to get the test block and test node for the scenario
|
|
46
48
|
* @export
|
|
@@ -48,10 +50,11 @@ export declare const handleTeardownSkipFlag: (directory: string) => Promise<void
|
|
|
48
50
|
* @param {string} content
|
|
49
51
|
* @return { testBlock: string; parentDescribe: string; } testBlock - the test block content, testNode - the test function node
|
|
50
52
|
*/
|
|
51
|
-
export declare function getTypescriptTestBlock({ scenarioName, suites, content, }: {
|
|
53
|
+
export declare function getTypescriptTestBlock({ scenarioName, suites, content, repoDir, }: {
|
|
52
54
|
scenarioName: string;
|
|
53
55
|
suites?: string[];
|
|
54
56
|
content: string;
|
|
57
|
+
repoDir: string;
|
|
55
58
|
}): {
|
|
56
59
|
testBlock: string | undefined;
|
|
57
60
|
testNode: Node | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAW,UAAU,EAAc,MAAM,UAAU,CAAC;AAIjE,OAAO,EAAsB,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGvE,wBAAsB,eAAe,CACnC,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"m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AM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG;IACF,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,UAAU,CAAC;CACxB,CAiDA"}
|
package/dist/utils/index.js
CHANGED
|
@@ -23,17 +23,17 @@ const util_1 = require("util");
|
|
|
23
23
|
const cmd_1 = require("../lib/cmd");
|
|
24
24
|
const types_1 = require("../types");
|
|
25
25
|
const config_1 = require("./config");
|
|
26
|
-
async function getAllFilePaths(directoryPath = "tests", filters = {}) {
|
|
26
|
+
async function getAllFilePaths(directoryPath = "tests", repoDir, filters = {}) {
|
|
27
27
|
let filePaths = [];
|
|
28
28
|
try {
|
|
29
|
-
const files = await promises_1.default.readdir(directoryPath);
|
|
29
|
+
const files = await promises_1.default.readdir(path_1.default.join(repoDir, directoryPath));
|
|
30
30
|
let allFilePaths = [];
|
|
31
31
|
for (const file of files) {
|
|
32
32
|
const filePath = path_1.default.join(directoryPath, file);
|
|
33
|
-
const stat = await promises_1.default.lstat(filePath);
|
|
33
|
+
const stat = await promises_1.default.lstat(path_1.default.join(repoDir, filePath));
|
|
34
34
|
if (stat.isDirectory()) {
|
|
35
35
|
// If it's a directory, recursively get file paths from the directory
|
|
36
|
-
const nestedFiles = await getAllFilePaths(filePath, filters);
|
|
36
|
+
const nestedFiles = await getAllFilePaths(filePath, repoDir, filters);
|
|
37
37
|
allFilePaths = allFilePaths.concat(nestedFiles);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
@@ -67,20 +67,22 @@ const getTestModuleAliasFromSourceFile = (sourceFile) => {
|
|
|
67
67
|
?.getText() || "test");
|
|
68
68
|
};
|
|
69
69
|
exports.getTestModuleAliasFromSourceFile = getTestModuleAliasFromSourceFile;
|
|
70
|
-
async function getTestCaseNode({ filePath, scenarioName, suites, }) {
|
|
71
|
-
const content = await promises_1.default.readFile(filePath, "utf-8");
|
|
70
|
+
async function getTestCaseNode({ filePath, scenarioName, suites, repoDir, }) {
|
|
71
|
+
const content = await promises_1.default.readFile(path_1.default.join(repoDir, filePath), "utf-8");
|
|
72
72
|
const { testNode, sourceFile } = getTypescriptTestBlock({
|
|
73
73
|
scenarioName,
|
|
74
74
|
content,
|
|
75
75
|
suites, // since this method is called on the generated content, not the whole file
|
|
76
|
+
repoDir,
|
|
76
77
|
});
|
|
77
78
|
return { testCaseNode: testNode, sourceFile };
|
|
78
79
|
}
|
|
79
|
-
async function hasTestBlock({ filePath, scenarioName, suites, }) {
|
|
80
|
+
async function hasTestBlock({ filePath, scenarioName, suites, repoDir, }) {
|
|
80
81
|
const { testCaseNode } = await getTestCaseNode({
|
|
81
82
|
filePath,
|
|
82
83
|
scenarioName,
|
|
83
84
|
suites,
|
|
85
|
+
repoDir,
|
|
84
86
|
});
|
|
85
87
|
return !!testCaseNode;
|
|
86
88
|
}
|
|
@@ -240,9 +242,9 @@ const getTestRunner = (platform) => {
|
|
|
240
242
|
: types_1.TestFramework.APPWRIGHT;
|
|
241
243
|
};
|
|
242
244
|
exports.getTestRunner = getTestRunner;
|
|
243
|
-
const getAllTeardownFiles = async (directory) => {
|
|
245
|
+
const getAllTeardownFiles = async (directory, repoDir) => {
|
|
244
246
|
const teardownFileRegex = /.*\.teardown\.ts/;
|
|
245
|
-
const files = await getAllFilePaths(directory);
|
|
247
|
+
const files = await getAllFilePaths(directory, repoDir);
|
|
246
248
|
return files.filter((file) => teardownFileRegex.test(file));
|
|
247
249
|
};
|
|
248
250
|
const skipTeardownFile = async (filePath) => {
|
|
@@ -266,13 +268,15 @@ const skipTeardownFile = async (filePath) => {
|
|
|
266
268
|
};
|
|
267
269
|
class TeardownManager {
|
|
268
270
|
directory;
|
|
269
|
-
|
|
271
|
+
repoDir;
|
|
272
|
+
constructor(directory, repoDir) {
|
|
270
273
|
this.directory = directory;
|
|
274
|
+
this.repoDir = repoDir;
|
|
271
275
|
}
|
|
272
276
|
teardownFiles = [];
|
|
273
277
|
teardownFileContents = [];
|
|
274
278
|
async skip() {
|
|
275
|
-
this.teardownFiles = await getAllTeardownFiles(this.directory);
|
|
279
|
+
this.teardownFiles = await getAllTeardownFiles(this.directory, this.repoDir);
|
|
276
280
|
this.teardownFileContents = await Promise.all(this.teardownFiles.map(async (filePath) => {
|
|
277
281
|
const content = await promises_1.default.readFile(filePath, "utf-8");
|
|
278
282
|
return { filePath, content };
|
|
@@ -285,9 +289,9 @@ class TeardownManager {
|
|
|
285
289
|
});
|
|
286
290
|
}
|
|
287
291
|
}
|
|
288
|
-
const handleTeardownSkipFlag = async (directory) => {
|
|
292
|
+
const handleTeardownSkipFlag = async (directory, repoDir) => {
|
|
289
293
|
console.log("Skipping teardown tests ...");
|
|
290
|
-
const teardowns = new TeardownManager(directory);
|
|
294
|
+
const teardowns = new TeardownManager(directory, repoDir);
|
|
291
295
|
await teardowns.skip();
|
|
292
296
|
// revert teardown changes on exit
|
|
293
297
|
process.on("beforeExit", () => {
|
|
@@ -332,9 +336,9 @@ const getParentDescribeNames = (node) => {
|
|
|
332
336
|
* @param {string} content
|
|
333
337
|
* @return { testBlock: string; parentDescribe: string; } testBlock - the test block content, testNode - the test function node
|
|
334
338
|
*/
|
|
335
|
-
function getTypescriptTestBlock({ scenarioName, suites, content, }) {
|
|
339
|
+
function getTypescriptTestBlock({ scenarioName, suites, content, repoDir, }) {
|
|
336
340
|
const project = new ts_morph_1.Project();
|
|
337
|
-
const sourceFile = project.createSourceFile("test.ts", content);
|
|
341
|
+
const sourceFile = project.createSourceFile(path_1.default.join(repoDir, "test.ts"), content);
|
|
338
342
|
const testAlias = (0, exports.getTestModuleAliasFromSourceFile)(sourceFile);
|
|
339
343
|
// Get all test function nodes that match the scenario name
|
|
340
344
|
const matchingTestFunctionNodes = sourceFile
|