@empiricalrun/test-run 0.4.0 → 0.4.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/bin/index.js +6 -3
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/dashboard.js +1 -1
- package/dist/run-specific-test.d.ts.map +1 -1
- package/dist/run-specific-test.js +17 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @empiricalrun/test-run
|
|
2
2
|
|
|
3
|
+
## 0.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 27716bd: fix: consider latest build url only when dispatch build url is not preset
|
|
8
|
+
|
|
9
|
+
## 0.4.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 00263d3: fix: revert file changes on process exit/kill
|
|
14
|
+
- ece893a: chore: error message for fetching environment
|
|
15
|
+
|
|
3
16
|
## 0.4.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/bin/index.js
CHANGED
|
@@ -40,11 +40,14 @@ const utils_1 = require("../utils");
|
|
|
40
40
|
let environmentSpecificProjects = [];
|
|
41
41
|
let platform = types_1.Platform.WEB;
|
|
42
42
|
if (process.env.TEST_RUN_ENVIRONMENT) {
|
|
43
|
-
const { environment, build } = await (0, dashboard_1.fetchEnvironmentAndBuild)();
|
|
43
|
+
const { environment, build: latestBuild } = await (0, dashboard_1.fetchEnvironmentAndBuild)();
|
|
44
44
|
platform = environment.platform;
|
|
45
45
|
environmentSpecificProjects = environment.playwright_projects;
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if (!process.env.BUILD_URL) {
|
|
47
|
+
process.env.BUILD_URL = latestBuild?.build_url; // pick the one coming from dispatch, otherwise use the latest build from DB
|
|
48
|
+
}
|
|
49
|
+
const buildUrl = process.env.BUILD_URL;
|
|
50
|
+
await (0, utils_1.downloadBuild)(buildUrl);
|
|
48
51
|
}
|
|
49
52
|
const projectFilters = await (0, utils_1.generateProjectFilters)({
|
|
50
53
|
platform,
|
package/dist/dashboard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAK7C,eAAO,MAAM,wBAAwB,QAAa,QAAQ;IACxD,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;CACd,
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAK7C,eAAO,MAAM,wBAAwB,QAAa,QAAQ;IACxD,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;CACd,CA6BA,CAAC"}
|
package/dist/dashboard.js
CHANGED
|
@@ -14,7 +14,7 @@ const fetchEnvironmentAndBuild = async () => {
|
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
16
|
if (!resp.ok) {
|
|
17
|
-
throw new Error(`Failed to fetch environment
|
|
17
|
+
throw new Error(`Failed to fetch environment from dashboard for project: ${projectRepo} and env slug: ${environmentSlug}. Use PROJECT_NAME and TEST_RUN_ENVIRONMENT env vars to set these values correctly.`);
|
|
18
18
|
}
|
|
19
19
|
const data = (await resp.json());
|
|
20
20
|
return data.data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-specific-test.d.ts","sourceRoot":"","sources":["../src/run-specific-test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAY5C;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,EACpC,IAAI,EACJ,GAAG,EACH,SAAS,EACT,QAAQ,GACT,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,
|
|
1
|
+
{"version":3,"file":"run-specific-test.d.ts","sourceRoot":"","sources":["../src/run-specific-test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAY5C;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,EACpC,IAAI,EACJ,GAAG,EACH,SAAS,EACT,QAAQ,GACT,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CAwED"}
|
|
@@ -37,6 +37,23 @@ async function runSpecificTest({ name, dir, pwOptions, platform, }) {
|
|
|
37
37
|
console.log("Is parent describe block marked serial:", !!parentDescribe);
|
|
38
38
|
console.log("Is file marked serial:", isFileMarkedSerial);
|
|
39
39
|
const currentFileContent = await fs_extra_1.default.readFile(matchingFilePath, "utf-8");
|
|
40
|
+
const revertFileContent = () => {
|
|
41
|
+
fs_extra_1.default.writeFileSync(matchingFilePath, currentFileContent);
|
|
42
|
+
};
|
|
43
|
+
// revert the changes made to the file to mark tests as only
|
|
44
|
+
// these needs to handle by listening to process exit/kill events
|
|
45
|
+
process.on("beforeExit", () => {
|
|
46
|
+
revertFileContent();
|
|
47
|
+
});
|
|
48
|
+
process.on("exit", () => {
|
|
49
|
+
revertFileContent();
|
|
50
|
+
});
|
|
51
|
+
process.on("SIGINT", () => {
|
|
52
|
+
revertFileContent();
|
|
53
|
+
});
|
|
54
|
+
process.on("SIGTERM", () => {
|
|
55
|
+
revertFileContent();
|
|
56
|
+
});
|
|
40
57
|
// if the file is not marked serial, we need to mark the test or describe block as only
|
|
41
58
|
if (!isFileMarkedSerial && testCaseNode) {
|
|
42
59
|
await (0, utils_1.markTestAsOnly)({
|
|
@@ -59,8 +76,6 @@ async function runSpecificTest({ name, dir, pwOptions, platform, }) {
|
|
|
59
76
|
catch (e) {
|
|
60
77
|
hasTestPassed = false;
|
|
61
78
|
}
|
|
62
|
-
// revert the changes made to the file to mark tests as only
|
|
63
|
-
await fs_extra_1.default.writeFile(matchingFilePath, currentFileContent);
|
|
64
79
|
return {
|
|
65
80
|
hasTestPassed,
|
|
66
81
|
};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node, SourceFile } from "ts-morph";
|
|
2
|
-
import {
|
|
2
|
+
import { Platform, TestFramework } from "../types";
|
|
3
3
|
export declare function cmd(command: string[], options: {
|
|
4
4
|
env?: Record<string, string>;
|
|
5
5
|
}): Promise<number>;
|
|
@@ -36,6 +36,6 @@ export declare const generateProjectFilters: ({ platform, filteringSets, }: {
|
|
|
36
36
|
filteringSets: string[];
|
|
37
37
|
}) => Promise<string[]>;
|
|
38
38
|
export declare function buildRepoName(projectName: string): string;
|
|
39
|
-
export declare const downloadBuild: (
|
|
39
|
+
export declare const downloadBuild: (buildUrl: string) => Promise<void>;
|
|
40
40
|
export declare const getTestRunner: (platform: Platform) => TestFramework;
|
|
41
41
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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;AAGjE,OAAO,
|
|
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;AAGjE,OAAO,EAAsB,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvE,wBAAgB,GAAG,CACjB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,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CAmBnB,CAAC;AAEF,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,eAAO,MAAM,aAAa,aAAoB,MAAM,KAAG,QAAQ,IAAI,CAWlE,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,QAAQ,KAAG,aAIlD,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -202,14 +202,14 @@ function buildRepoName(projectName) {
|
|
|
202
202
|
return `${projectName}-tests`;
|
|
203
203
|
}
|
|
204
204
|
exports.buildRepoName = buildRepoName;
|
|
205
|
-
const downloadBuild = async (
|
|
205
|
+
const downloadBuild = async (buildUrl) => {
|
|
206
206
|
const packageJSONPath = "package.json";
|
|
207
207
|
const packageJsonStr = await fs_extra_1.default.readFile(packageJSONPath, "utf-8");
|
|
208
208
|
const packageJSONData = JSON.parse(packageJsonStr);
|
|
209
209
|
const buildDownloadScript = packageJSONData.scripts["download"];
|
|
210
|
-
if (buildDownloadScript &&
|
|
211
|
-
console.log(`Downloading build from ${
|
|
212
|
-
await cmd(`npm run download ${
|
|
210
|
+
if (buildDownloadScript && buildUrl) {
|
|
211
|
+
console.log(`Downloading build from ${buildUrl}`);
|
|
212
|
+
await cmd(`npm run download ${buildUrl}`.split(" "), {
|
|
213
213
|
env: { ...Object(process.env) },
|
|
214
214
|
});
|
|
215
215
|
}
|