@empiricalrun/test-run 0.3.1 → 0.4.1

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @empiricalrun/test-run
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 00263d3: fix: revert file changes on process exit/kill
8
+ - ece893a: chore: error message for fetching environment
9
+
10
+ ## 0.4.0
11
+
12
+ ### Minor Changes
13
+
14
+ - bc34d28: feat: support calling appwright from test-run package
15
+
3
16
  ## 0.3.1
4
17
 
5
18
  ### Patch 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,20 +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
43
  const { environment, build } = await (0, dashboard_1.fetchEnvironmentAndBuild)();
44
+ platform = environment.platform;
42
45
  environmentSpecificProjects = environment.playwright_projects;
43
46
  await (0, utils_1.downloadBuild)(build);
47
+ process.env.BUILD_URL = build?.build_url;
44
48
  }
45
- const projectFilters = await (0, utils_1.generateProjectFilters)([
46
- ...options.project,
47
- ...environmentSpecificProjects,
48
- ]);
49
+ const projectFilters = await (0, utils_1.generateProjectFilters)({
50
+ platform,
51
+ filteringSets: [...options.project, ...environmentSpecificProjects],
52
+ });
49
53
  pwOptions.push(...projectFilters);
50
54
  const { hasTestPassed } = await (0, __1.runTest)({
51
55
  name: options.name,
52
56
  dir: options.dir || "tests",
53
57
  pwOptions: pwOptions.join(" "),
58
+ platform,
54
59
  });
55
60
  if (!hasTestPassed) {
56
61
  process.exit(1);
@@ -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,CA2BA,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,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 details from dashboard`);
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;
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
@@ -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,GACV,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CAMD"}
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;
@@ -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":"AAEA;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,EAChC,SAAS,GACV,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC;IACV,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CAkBD"}
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"}
@@ -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 pwRunCmd = `npx playwright test ${pwOptions}`;
15
- console.log("Playwright test command:", pwRunCmd, {
16
- arr: pwRunCmd.split(" "),
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)(pwRunCmd.split(" "), {
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;AAW5C;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,EACpC,IAAI,EACJ,GAAG,EACH,SAAS,GACV,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CAoDD"}
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"}
@@ -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
@@ -37,6 +37,23 @@ async function runSpecificTest({ name, dir, pwOptions, }) {
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)({
@@ -48,18 +65,17 @@ async function runSpecificTest({ name, dir, pwOptions, }) {
48
65
  }
49
66
  let hasTestPassed = true;
50
67
  try {
68
+ const testRunner = (0, utils_1.getTestRunner)(platform);
51
69
  const env = Object({ ...process.env });
52
- const pwRunCmd = `npx playwright test ${matchingFilePath} ${pwOptions}`;
53
- console.log("Playwright test command:", pwRunCmd);
54
- await (0, utils_1.cmd)(pwRunCmd.split(" "), {
70
+ const testRunCmd = `npx ${testRunner} test ${matchingFilePath} ${pwOptions}`;
71
+ console.log(`${testRunner} test command:`, testRunCmd);
72
+ await (0, utils_1.cmd)(testRunCmd.split(" "), {
55
73
  env,
56
74
  });
57
75
  }
58
76
  catch (e) {
59
77
  hasTestPassed = false;
60
78
  }
61
- // revert the changes made to the file to mark tests as only
62
- await fs_extra_1.default.writeFile(matchingFilePath, currentFileContent);
63
79
  return {
64
80
  hasTestPassed,
65
81
  };
@@ -2,12 +2,14 @@ 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
  };
12
14
  export type Build = {
13
15
  id: number;
@@ -16,4 +18,13 @@ export type Build = {
16
18
  export type PartialPackageJSON = {
17
19
  scripts: Record<string, string>;
18
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
+ }
19
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;CAC/B,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"}
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"}
@@ -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 = {}));
@@ -1,5 +1,5 @@
1
1
  import { Node, SourceFile } from "ts-morph";
2
- import { Build } from "../types";
2
+ import { Build, Platform, TestFramework } from "../types";
3
3
  export declare function cmd(command: string[], options: {
4
4
  env?: Record<string, string>;
5
5
  }): Promise<number>;
@@ -29,9 +29,13 @@ export declare function markTestAsOnly({ sourceFile, parentDescribeNode, testCas
29
29
  testCaseNode: Node;
30
30
  filePath: string;
31
31
  }): Promise<void>;
32
- export declare function getProjectsFromPlaywrightConfig(): Promise<string[]>;
32
+ export declare function getProjectsFromPlaywrightConfig(platform: Platform): Promise<any>;
33
33
  export declare const filterArrayByGlobMatchersSet: (input: string[], globMatcherSets: string[][]) => string[];
34
- export declare const generateProjectFilters: (filteringSets: string[]) => Promise<string[]>;
34
+ export declare const generateProjectFilters: ({ platform, filteringSets, }: {
35
+ platform: Platform;
36
+ filteringSets: string[];
37
+ }) => Promise<string[]>;
35
38
  export declare function buildRepoName(projectName: string): string;
36
39
  export declare const downloadBuild: (build: Build) => Promise<void>;
40
+ export declare const getTestRunner: (platform: Platform) => TestFramework;
37
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,EAAE,KAAK,EAAsB,MAAM,UAAU,CAAC;AAErD,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,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAczE;AAED,eAAO,MAAM,4BAA4B,UAEhC,MAAM,EAAE,mBAGE,MAAM,EAAE,EAAE,KAC1B,MAAM,EAUR,CAAC;AAEF,eAAO,MAAM,sBAAsB,kBAClB,MAAM,EAAE,KACtB,QAAQ,MAAM,EAAE,CAkBlB,CAAC;AAEF,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,eAAO,MAAM,aAAa,UAAiB,KAAK,KAAG,QAAQ,IAAI,CAW9D,CAAC"}
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"}
@@ -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.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;
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) {
@@ -214,3 +215,9 @@ const downloadBuild = async (build) => {
214
215
  }
215
216
  };
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-run",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"