@empiricalrun/test-run 0.3.0 → 0.4.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/bin/index.js +12 -6
- package/dist/dashboard.d.ts +5 -2
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/dashboard.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/run-all-tests.d.ts +3 -1
- package/dist/run-all-tests.d.ts.map +1 -1
- package/dist/run-all-tests.js +6 -5
- package/dist/run-specific-test.d.ts +1 -1
- package/dist/run-specific-test.d.ts.map +1 -1
- package/dist/run-specific-test.js +5 -4
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +12 -0
- package/dist/utils/index.d.ts +8 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +25 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @empiricalrun/test-run
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bc34d28: feat: support calling appwright from test-run package
|
|
8
|
+
|
|
9
|
+
## 0.3.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 1d2d9fc: fix: download latest build before running tests
|
|
14
|
+
|
|
3
15
|
## 0.3.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/bin/index.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
5
|
const __1 = require("..");
|
|
6
6
|
const dashboard_1 = require("../dashboard");
|
|
7
|
+
const types_1 = require("../types");
|
|
7
8
|
const utils_1 = require("../utils");
|
|
8
9
|
(async function main() {
|
|
9
10
|
// TODO: add support for suites
|
|
@@ -37,19 +38,24 @@ const utils_1 = require("../utils");
|
|
|
37
38
|
.filter((arg) => !optionsToStrip.includes(arg));
|
|
38
39
|
try {
|
|
39
40
|
let environmentSpecificProjects = [];
|
|
41
|
+
let platform = types_1.Platform.WEB;
|
|
40
42
|
if (process.env.TEST_RUN_ENVIRONMENT) {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
+
const { environment, build } = await (0, dashboard_1.fetchEnvironmentAndBuild)();
|
|
44
|
+
platform = environment.platform;
|
|
45
|
+
environmentSpecificProjects = environment.playwright_projects;
|
|
46
|
+
await (0, utils_1.downloadBuild)(build);
|
|
47
|
+
process.env.BUILD_URL = build?.build_url;
|
|
43
48
|
}
|
|
44
|
-
const projectFilters = await (0, utils_1.generateProjectFilters)(
|
|
45
|
-
|
|
46
|
-
...environmentSpecificProjects,
|
|
47
|
-
|
|
49
|
+
const projectFilters = await (0, utils_1.generateProjectFilters)({
|
|
50
|
+
platform,
|
|
51
|
+
filteringSets: [...options.project, ...environmentSpecificProjects],
|
|
52
|
+
});
|
|
48
53
|
pwOptions.push(...projectFilters);
|
|
49
54
|
const { hasTestPassed } = await (0, __1.runTest)({
|
|
50
55
|
name: options.name,
|
|
51
56
|
dir: options.dir || "tests",
|
|
52
57
|
pwOptions: pwOptions.join(" "),
|
|
58
|
+
platform,
|
|
53
59
|
});
|
|
54
60
|
if (!hasTestPassed) {
|
|
55
61
|
process.exit(1);
|
package/dist/dashboard.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import { Environment } from "./types";
|
|
2
|
-
export declare const
|
|
1
|
+
import { Build, Environment } from "./types";
|
|
2
|
+
export declare const fetchEnvironmentAndBuild: () => Promise<{
|
|
3
|
+
environment: Environment;
|
|
4
|
+
build: Build;
|
|
5
|
+
}>;
|
|
3
6
|
//# 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":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
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,CA2BA,CAAC"}
|
package/dist/dashboard.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.fetchEnvironmentAndBuild = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
const DOMAIN = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
|
|
6
|
-
const
|
|
6
|
+
const fetchEnvironmentAndBuild = async () => {
|
|
7
7
|
const projectRepo = (0, utils_1.buildRepoName)(process.env.PROJECT_NAME);
|
|
8
8
|
const environmentSlug = `${process.env.TEST_RUN_ENVIRONMENT}`;
|
|
9
9
|
const resp = await fetch(`${DOMAIN}/api/environments?project_repo_name=${projectRepo}&environment_slug=${environmentSlug}`, {
|
|
@@ -17,6 +17,6 @@ const fetchEnvironment = async () => {
|
|
|
17
17
|
throw new Error(`Failed to fetch environment details from dashboard`);
|
|
18
18
|
}
|
|
19
19
|
const data = (await resp.json());
|
|
20
|
-
return data.data
|
|
20
|
+
return data.data;
|
|
21
21
|
};
|
|
22
|
-
exports.
|
|
22
|
+
exports.fetchEnvironmentAndBuild = fetchEnvironmentAndBuild;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { TestRunParameters } from "./types";
|
|
|
4
4
|
* @export
|
|
5
5
|
* @param {TestRunParameters} { name, dir, pwOptions }
|
|
6
6
|
*/
|
|
7
|
-
export declare function runTest({ name, dir, pwOptions, }: TestRunParameters): Promise<{
|
|
7
|
+
export declare function runTest({ name, dir, pwOptions, platform, }: TestRunParameters): Promise<{
|
|
8
8
|
hasTestPassed: boolean;
|
|
9
9
|
}>;
|
|
10
10
|
//# 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":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,EAC5B,IAAI,EACJ,GAAG,EACH,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,EAC5B,IAAI,EACJ,GAAG,EACH,SAAS,EACT,QAAQ,GACT,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CAMD"}
|
package/dist/index.js
CHANGED
|
@@ -8,10 +8,10 @@ const run_specific_test_1 = require("./run-specific-test");
|
|
|
8
8
|
* @export
|
|
9
9
|
* @param {TestRunParameters} { name, dir, pwOptions }
|
|
10
10
|
*/
|
|
11
|
-
async function runTest({ name, dir, pwOptions, }) {
|
|
11
|
+
async function runTest({ name, dir, pwOptions, platform, }) {
|
|
12
12
|
if (name) {
|
|
13
|
-
return await (0, run_specific_test_1.runSpecificTest)({ name, dir, pwOptions });
|
|
13
|
+
return await (0, run_specific_test_1.runSpecificTest)({ name, dir, pwOptions, platform });
|
|
14
14
|
}
|
|
15
|
-
return await (0, run_all_tests_1.runAllTests)({ pwOptions });
|
|
15
|
+
return await (0, run_all_tests_1.runAllTests)({ pwOptions, platform });
|
|
16
16
|
}
|
|
17
17
|
exports.runTest = runTest;
|
package/dist/run-all-tests.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { Platform } from "./types";
|
|
1
2
|
/**
|
|
2
3
|
*
|
|
3
4
|
* @export
|
|
4
5
|
* @param {TestRunParameters} { name, dir, pwOptions }
|
|
5
6
|
*/
|
|
6
|
-
export declare function runAllTests({ pwOptions, }: {
|
|
7
|
+
export declare function runAllTests({ pwOptions, platform, }: {
|
|
7
8
|
pwOptions?: string;
|
|
9
|
+
platform: Platform;
|
|
8
10
|
}): Promise<{
|
|
9
11
|
hasTestPassed: boolean;
|
|
10
12
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-all-tests.d.ts","sourceRoot":"","sources":["../src/run-all-tests.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-all-tests.d.ts","sourceRoot":"","sources":["../src/run-all-tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,EAChC,SAAS,EACT,QAAQ,GACT,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACpB,GAAG,OAAO,CAAC;IACV,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CAoBD"}
|
package/dist/run-all-tests.js
CHANGED
|
@@ -7,15 +7,16 @@ const utils_1 = require("./utils");
|
|
|
7
7
|
* @export
|
|
8
8
|
* @param {TestRunParameters} { name, dir, pwOptions }
|
|
9
9
|
*/
|
|
10
|
-
async function runAllTests({ pwOptions, }) {
|
|
10
|
+
async function runAllTests({ pwOptions, platform, }) {
|
|
11
11
|
let hasTestPassed = true;
|
|
12
12
|
try {
|
|
13
|
+
const testRunner = (0, utils_1.getTestRunner)(platform);
|
|
13
14
|
const env = Object({ ...process.env });
|
|
14
|
-
const
|
|
15
|
-
console.log(
|
|
16
|
-
arr:
|
|
15
|
+
const testRunCmd = `npx ${testRunner} test ${pwOptions}`;
|
|
16
|
+
console.log(`${testRunner} test command:`, testRunCmd, {
|
|
17
|
+
arr: testRunCmd.split(" "),
|
|
17
18
|
});
|
|
18
|
-
await (0, utils_1.cmd)(
|
|
19
|
+
await (0, utils_1.cmd)(testRunCmd.split(" "), {
|
|
19
20
|
env,
|
|
20
21
|
});
|
|
21
22
|
}
|
|
@@ -4,7 +4,7 @@ import { TestRunParameters } from "./types";
|
|
|
4
4
|
* @export
|
|
5
5
|
* @param {TestRunParameters} { name, dir, pwOptions }
|
|
6
6
|
*/
|
|
7
|
-
export declare function runSpecificTest({ name, dir, pwOptions, }: TestRunParameters): Promise<{
|
|
7
|
+
export declare function runSpecificTest({ name, dir, pwOptions, platform, }: TestRunParameters): Promise<{
|
|
8
8
|
hasTestPassed: boolean;
|
|
9
9
|
}>;
|
|
10
10
|
//# sourceMappingURL=run-specific-test.d.ts.map
|
|
@@ -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;
|
|
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,CAsDD"}
|
|
@@ -11,7 +11,7 @@ const utils_1 = require("./utils");
|
|
|
11
11
|
* @export
|
|
12
12
|
* @param {TestRunParameters} { name, dir, pwOptions }
|
|
13
13
|
*/
|
|
14
|
-
async function runSpecificTest({ name, dir, pwOptions, }) {
|
|
14
|
+
async function runSpecificTest({ name, dir, pwOptions, platform, }) {
|
|
15
15
|
const files = await (0, utils_1.getAllFilePaths)(dir);
|
|
16
16
|
let matchingFilePath = "";
|
|
17
17
|
// find the first file that contains the test block
|
|
@@ -48,10 +48,11 @@ async function runSpecificTest({ name, dir, pwOptions, }) {
|
|
|
48
48
|
}
|
|
49
49
|
let hasTestPassed = true;
|
|
50
50
|
try {
|
|
51
|
+
const testRunner = (0, utils_1.getTestRunner)(platform);
|
|
51
52
|
const env = Object({ ...process.env });
|
|
52
|
-
const
|
|
53
|
-
console.log(
|
|
54
|
-
await (0, utils_1.cmd)(
|
|
53
|
+
const testRunCmd = `npx ${testRunner} test ${matchingFilePath} ${pwOptions}`;
|
|
54
|
+
console.log(`${testRunner} test command:`, testRunCmd);
|
|
55
|
+
await (0, utils_1.cmd)(testRunCmd.split(" "), {
|
|
55
56
|
env,
|
|
56
57
|
});
|
|
57
58
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,11 +2,29 @@ export type TestRunParameters = {
|
|
|
2
2
|
name: string;
|
|
3
3
|
dir?: string;
|
|
4
4
|
pwOptions?: string;
|
|
5
|
+
platform: Platform;
|
|
5
6
|
};
|
|
6
7
|
export type Environment = {
|
|
7
8
|
id: number;
|
|
8
9
|
project_id: number;
|
|
9
10
|
slug: string;
|
|
10
11
|
playwright_projects: string[];
|
|
12
|
+
platform: Platform;
|
|
11
13
|
};
|
|
14
|
+
export type Build = {
|
|
15
|
+
id: number;
|
|
16
|
+
build_url: string;
|
|
17
|
+
};
|
|
18
|
+
export type PartialPackageJSON = {
|
|
19
|
+
scripts: Record<string, string>;
|
|
20
|
+
};
|
|
21
|
+
export declare enum Platform {
|
|
22
|
+
WEB = "web",
|
|
23
|
+
ANDROID = "android",
|
|
24
|
+
IOS = "ios"
|
|
25
|
+
}
|
|
26
|
+
export declare enum TestFramework {
|
|
27
|
+
PLAYWRIGHT = "playwright",
|
|
28
|
+
APPWRIGHT = "appwright"
|
|
29
|
+
}
|
|
12
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,CAAC;AAEF,oBAAY,QAAQ;IAClB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,GAAG,QAAQ;CACZ;AAED,oBAAY,aAAa;IACvB,UAAU,eAAe;IACzB,SAAS,cAAc;CACxB"}
|
package/dist/types/index.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestFramework = exports.Platform = void 0;
|
|
4
|
+
var Platform;
|
|
5
|
+
(function (Platform) {
|
|
6
|
+
Platform["WEB"] = "web";
|
|
7
|
+
Platform["ANDROID"] = "android";
|
|
8
|
+
Platform["IOS"] = "ios";
|
|
9
|
+
})(Platform || (exports.Platform = Platform = {}));
|
|
10
|
+
var TestFramework;
|
|
11
|
+
(function (TestFramework) {
|
|
12
|
+
TestFramework["PLAYWRIGHT"] = "playwright";
|
|
13
|
+
TestFramework["APPWRIGHT"] = "appwright";
|
|
14
|
+
})(TestFramework || (exports.TestFramework = TestFramework = {}));
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Node, SourceFile } from "ts-morph";
|
|
2
|
+
import { Build, Platform, TestFramework } from "../types";
|
|
2
3
|
export declare function cmd(command: string[], options: {
|
|
3
4
|
env?: Record<string, string>;
|
|
4
5
|
}): Promise<number>;
|
|
@@ -28,8 +29,13 @@ export declare function markTestAsOnly({ sourceFile, parentDescribeNode, testCas
|
|
|
28
29
|
testCaseNode: Node;
|
|
29
30
|
filePath: string;
|
|
30
31
|
}): Promise<void>;
|
|
31
|
-
export declare function getProjectsFromPlaywrightConfig(): Promise<
|
|
32
|
+
export declare function getProjectsFromPlaywrightConfig(platform: Platform): Promise<any>;
|
|
32
33
|
export declare const filterArrayByGlobMatchersSet: (input: string[], globMatcherSets: string[][]) => string[];
|
|
33
|
-
export declare const generateProjectFilters: (filteringSets:
|
|
34
|
+
export declare const generateProjectFilters: ({ platform, filteringSets, }: {
|
|
35
|
+
platform: Platform;
|
|
36
|
+
filteringSets: string[];
|
|
37
|
+
}) => Promise<string[]>;
|
|
34
38
|
export declare function buildRepoName(projectName: string): string;
|
|
39
|
+
export declare const downloadBuild: (build: Build) => Promise<void>;
|
|
40
|
+
export declare const getTestRunner: (platform: Platform) => TestFramework;
|
|
35
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,wBAAgB,GAAG,CACjB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACxC,OAAO,CAAC,MAAM,CAAC,CA2BjB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,aAAa,GAAE,MAAW,GACzB,OAAO,CAAC,MAAM,EAAE,CAAC,CAqBnB;AAED,wBAAsB,eAAe,CAAC,EACpC,QAAQ,EACR,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC;IAAE,YAAY,EAAE,IAAI,GAAG,SAAS,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC,CAatE;AAED,wBAAsB,YAAY,CAAC,EACjC,QAAQ,EACR,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,CAAC,CAMnB;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,GAAG,SAAS,GACrB,IAAI,GAAG,SAAS,CA2BlB;AAED,wBAAsB,0CAA0C,CAC9D,QAAQ,EAAE,MAAM,oBA+BjB;AAED,wBAAsB,cAAc,CAAC,EACnC,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,kBAAkB,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IACtC,YAAY,EAAE,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAgBA;AAED,wBAAsB,+BAA+B,
|
|
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,EAAE,KAAK,EAAsB,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9E,wBAAgB,GAAG,CACjB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACxC,OAAO,CAAC,MAAM,CAAC,CA2BjB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,aAAa,GAAE,MAAW,GACzB,OAAO,CAAC,MAAM,EAAE,CAAC,CAqBnB;AAED,wBAAsB,eAAe,CAAC,EACpC,QAAQ,EACR,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC;IAAE,YAAY,EAAE,IAAI,GAAG,SAAS,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC,CAatE;AAED,wBAAsB,YAAY,CAAC,EACjC,QAAQ,EACR,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,CAAC,CAMnB;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,GAAG,SAAS,GACrB,IAAI,GAAG,SAAS,CA2BlB;AAED,wBAAsB,0CAA0C,CAC9D,QAAQ,EAAE,MAAM,oBA+BjB;AAED,wBAAsB,cAAc,CAAC,EACnC,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,kBAAkB,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IACtC,YAAY,EAAE,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAgBA;AAED,wBAAsB,+BAA+B,CAAC,QAAQ,EAAE,QAAQ,gBAevE;AAED,eAAO,MAAM,4BAA4B,UAEhC,MAAM,EAAE,mBAGE,MAAM,EAAE,EAAE,KAC1B,MAAM,EAUR,CAAC;AAEF,eAAO,MAAM,sBAAsB;cAIvB,QAAQ;mBACH,MAAM,EAAE;MACrB,QAAQ,MAAM,EAAE,CAmBnB,CAAC;AAEF,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,eAAO,MAAM,aAAa,UAAiB,KAAK,KAAG,QAAQ,IAAI,CAW9D,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,QAAQ,KAAG,aAIlD,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -3,13 +3,14 @@ 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.buildRepoName = exports.generateProjectFilters = exports.filterArrayByGlobMatchersSet = exports.getProjectsFromPlaywrightConfig = exports.markTestAsOnly = exports.hasTopLevelDescribeConfigureWithSerialMode = exports.findFirstSerialDescribeBlock = exports.hasTestBlock = exports.getTestCaseNode = exports.getAllFilePaths = exports.cmd = void 0;
|
|
6
|
+
exports.getTestRunner = exports.downloadBuild = exports.buildRepoName = exports.generateProjectFilters = exports.filterArrayByGlobMatchersSet = exports.getProjectsFromPlaywrightConfig = exports.markTestAsOnly = exports.hasTopLevelDescribeConfigureWithSerialMode = exports.findFirstSerialDescribeBlock = exports.hasTestBlock = exports.getTestCaseNode = exports.getAllFilePaths = exports.cmd = void 0;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const minimatch_1 = require("minimatch");
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const ts_morph_1 = require("ts-morph");
|
|
12
12
|
const api_1 = require("tsx/esm/api");
|
|
13
|
+
const types_1 = require("../types");
|
|
13
14
|
function cmd(command, options) {
|
|
14
15
|
let errorLogs = [];
|
|
15
16
|
return new Promise((resolveFunc, rejectFunc) => {
|
|
@@ -159,8 +160,8 @@ async function markTestAsOnly({ sourceFile, parentDescribeNode, testCaseNode, fi
|
|
|
159
160
|
await fs_extra_1.default.writeFile(filePath, updatedTestFileContent, "utf-8");
|
|
160
161
|
}
|
|
161
162
|
exports.markTestAsOnly = markTestAsOnly;
|
|
162
|
-
async function getProjectsFromPlaywrightConfig() {
|
|
163
|
-
const configName = "playwright.config.ts";
|
|
163
|
+
async function getProjectsFromPlaywrightConfig(platform) {
|
|
164
|
+
const configName = platform === types_1.Platform.WEB ? "playwright.config.ts" : "appwright.config.ts";
|
|
164
165
|
const directoryPath = ".";
|
|
165
166
|
const pwFile = path_1.default.resolve(directoryPath, configName);
|
|
166
167
|
try {
|
|
@@ -187,8 +188,8 @@ globMatcherSets) => {
|
|
|
187
188
|
return filteredList;
|
|
188
189
|
};
|
|
189
190
|
exports.filterArrayByGlobMatchersSet = filterArrayByGlobMatchersSet;
|
|
190
|
-
const generateProjectFilters = async (filteringSets) => {
|
|
191
|
-
const projectsDefinedInPwConfig = await getProjectsFromPlaywrightConfig();
|
|
191
|
+
const generateProjectFilters = async ({ platform, filteringSets, }) => {
|
|
192
|
+
const projectsDefinedInPwConfig = await getProjectsFromPlaywrightConfig(platform);
|
|
192
193
|
const filters = filteringSets.map((matchingString) => matchingString.split(","));
|
|
193
194
|
const filteredProjects = (0, exports.filterArrayByGlobMatchersSet)(projectsDefinedInPwConfig, filters);
|
|
194
195
|
if (filteredProjects.length === 0) {
|
|
@@ -201,3 +202,22 @@ function buildRepoName(projectName) {
|
|
|
201
202
|
return `${projectName}-tests`;
|
|
202
203
|
}
|
|
203
204
|
exports.buildRepoName = buildRepoName;
|
|
205
|
+
const downloadBuild = async (build) => {
|
|
206
|
+
const packageJSONPath = "package.json";
|
|
207
|
+
const packageJsonStr = await fs_extra_1.default.readFile(packageJSONPath, "utf-8");
|
|
208
|
+
const packageJSONData = JSON.parse(packageJsonStr);
|
|
209
|
+
const buildDownloadScript = packageJSONData.scripts["download"];
|
|
210
|
+
if (buildDownloadScript && build?.build_url) {
|
|
211
|
+
console.log(`Downloading build from ${build?.build_url}`);
|
|
212
|
+
await cmd(`npm run download ${build?.build_url}`.split(" "), {
|
|
213
|
+
env: { ...Object(process.env) },
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
exports.downloadBuild = downloadBuild;
|
|
218
|
+
const getTestRunner = (platform) => {
|
|
219
|
+
return platform === types_1.Platform.WEB
|
|
220
|
+
? types_1.TestFramework.PLAYWRIGHT
|
|
221
|
+
: types_1.TestFramework.APPWRIGHT;
|
|
222
|
+
};
|
|
223
|
+
exports.getTestRunner = getTestRunner;
|