@empiricalrun/test-run 0.9.1 → 0.9.3

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,19 @@
1
1
  # @empiricalrun/test-run
2
2
 
3
+ ## 0.9.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 333b99f: fix: test run tool should report correct status
8
+ - 3739bc0: fix: replace tsx with an execSync call to fetch playwright projects
9
+
10
+ ## 0.9.2
11
+
12
+ ### Patch Changes
13
+
14
+ - d71508f: chore: set playwright runs to headed based on env key
15
+ - fca6729: feat: implement TypeScript compiler execution and error handling in strReplaceEditor
16
+
3
17
  ## 0.9.1
4
18
 
5
19
  ### Patch Changes
package/dist/bin/index.js CHANGED
@@ -95,6 +95,7 @@ dotenv_1.default.config({
95
95
  const projectFilters = await (0, utils_1.generateProjectFilters)({
96
96
  platform,
97
97
  filteringSets: [...options.project, ...environmentSpecificProjects],
98
+ repoDir: process.cwd(),
98
99
  });
99
100
  if (options.skipTeardown) {
100
101
  await (0, utils_1.handleTeardownSkipFlag)(directory);
@@ -107,6 +108,7 @@ dotenv_1.default.config({
107
108
  projects: projectFilters,
108
109
  passthroughArgs: pwOptions.join(" "),
109
110
  platform,
111
+ repoDir: process.cwd(),
110
112
  });
111
113
  }
112
114
  else {
package/dist/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
+ import { spawnCmd } from "./lib/cmd";
1
2
  import { runSpecificTestsCmd } from "./lib/run-specific-test";
2
3
  import { TestCase } from "./types";
3
- export { runSpecificTestsCmd };
4
- export declare function runSingleTest({ testName, suites, fileName, projects, envOverrides, }: {
4
+ export { runSpecificTestsCmd, spawnCmd };
5
+ export declare function runSingleTest({ testName, suites, fileName, projects, envOverrides, repoDir, }: {
5
6
  testName: string;
6
7
  suites: string[];
7
8
  fileName: string;
8
9
  projects: string[];
9
10
  envOverrides?: Record<string, string>;
11
+ repoDir: string;
10
12
  }): Promise<{
11
13
  hasTestPassed: boolean;
12
14
  summaryJson: any;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAY,QAAQ,EAAE,MAAM,SAAS,CAAC;AAO7C,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,wBAAsB,aAAa,CAAC,EAClC,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;;;GAqBA;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACvE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;CACjD,CAAC,CAaD"}
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,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAY,QAAQ,EAAE,MAAM,SAAS,CAAC;AAO7C,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC;AAEzC,wBAAsB,aAAa,CAAC,EAClC,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;;;GAkBA;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACvE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;CACjD,CAAC,CAaD"}
package/dist/index.js CHANGED
@@ -3,12 +3,13 @@ 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.runSpecificTestsCmd = void 0;
6
+ exports.spawnCmd = exports.runSpecificTestsCmd = void 0;
7
7
  exports.runSingleTest = runSingleTest;
8
8
  exports.getAllPlaywrightProjects = getAllPlaywrightProjects;
9
9
  const promises_1 = __importDefault(require("fs/promises"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const cmd_1 = require("./lib/cmd");
12
+ Object.defineProperty(exports, "spawnCmd", { enumerable: true, get: function () { return cmd_1.spawnCmd; } });
12
13
  const run_specific_test_1 = require("./lib/run-specific-test");
13
14
  Object.defineProperty(exports, "runSpecificTestsCmd", { enumerable: true, get: function () { return run_specific_test_1.runSpecificTestsCmd; } });
14
15
  const parser_1 = require("./parser");
@@ -17,17 +18,18 @@ const utils_1 = require("./utils");
17
18
  // For test-run package, the library entrypoint, we only support web platform
18
19
  // The bin entrypoint has support for mobile also
19
20
  const supportedPlatform = types_1.Platform.WEB;
20
- async function runSingleTest({ testName, suites, fileName, projects, envOverrides, }) {
21
+ async function runSingleTest({ testName, suites, fileName, projects, envOverrides, repoDir, }) {
21
22
  const testDir = "tests";
22
- const filePath = path_1.default.relative(process.cwd(), fileName);
23
+ const filePath = path_1.default.relative(repoDir, fileName);
23
24
  const commandToRun = await (0, run_specific_test_1.runSpecificTestsCmd)({
24
25
  tests: [{ name: testName, dir: testDir, filePath, suites }],
25
26
  projects,
26
27
  envOverrides,
27
28
  platform: supportedPlatform,
29
+ repoDir,
28
30
  });
29
31
  const { hasTestPassed } = await (0, cmd_1.runTestsForCmd)(commandToRun);
30
- const jsonFilePath = path_1.default.join(process.cwd(), "playwright-report", `summary.json`);
32
+ const jsonFilePath = path_1.default.join(repoDir, "playwright-report", `summary.json`);
31
33
  const jsonFileContents = await promises_1.default.readFile(jsonFilePath, "utf8");
32
34
  const summaryJson = JSON.parse(jsonFileContents);
33
35
  return {
@@ -37,12 +39,12 @@ async function runSingleTest({ testName, suites, fileName, projects, envOverride
37
39
  }
38
40
  async function getAllPlaywrightProjects(repoDir) {
39
41
  const testRunner = (0, utils_1.getTestRunner)(types_1.Platform.WEB);
40
- const env = Object({ ...process.env });
41
42
  const args = [testRunner, "test", "--list"];
42
43
  const { output, code } = await (0, cmd_1.spawnCmd)("npx", args, {
43
- env,
44
44
  cwd: repoDir,
45
+ envOverrides: {},
45
46
  captureOutput: true,
47
+ throwOnError: true,
46
48
  });
47
49
  if (!output) {
48
50
  throw new Error(`Failed to run list command; exit code: ${code}`);
package/dist/lib/cmd.d.ts CHANGED
@@ -7,9 +7,10 @@ export declare function runTestsForCmd({ command, args, env }: CommandToRun): Pr
7
7
  hasTestPassed: boolean;
8
8
  }>;
9
9
  export declare function spawnCmd(command: string, args: string[], options: {
10
- env?: Record<string, string>;
11
- cwd?: string;
12
- captureOutput?: boolean;
10
+ cwd: string;
11
+ envOverrides: Record<string, string>;
12
+ captureOutput: boolean;
13
+ throwOnError: boolean;
13
14
  }): Promise<{
14
15
  code: number;
15
16
  output?: string;
@@ -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,wBAA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A6C5C"}
package/dist/lib/cmd.js CHANGED
@@ -22,7 +22,12 @@ async function runTestsForCmd({ command, args, env }) {
22
22
  console.log(`Running cmd: ${command} with args: ${args}`);
23
23
  let hasTestPassed = true;
24
24
  try {
25
- await spawnCmd(command, args, { env });
25
+ await spawnCmd(command, args, {
26
+ cwd: process.cwd(),
27
+ envOverrides: env,
28
+ captureOutput: false,
29
+ throwOnError: true,
30
+ });
26
31
  }
27
32
  catch (e) {
28
33
  hasTestPassed = false;
@@ -34,7 +39,7 @@ async function spawnCmd(command, args, options) {
34
39
  let errorLogs = [];
35
40
  return new Promise((resolveFunc, rejectFunc) => {
36
41
  const p = (0, child_process_1.spawn)(command, args, {
37
- env: { ...process.env, ...options.env },
42
+ env: { ...process.env, ...options.envOverrides },
38
43
  cwd: options.cwd,
39
44
  // Ensure child process receives signals
40
45
  detached: false,
@@ -61,7 +66,7 @@ async function spawnCmd(command, args, options) {
61
66
  p.on("exit", (code) => {
62
67
  // Clean up signal handlers when the process exits
63
68
  cleanupSignalHandlers();
64
- if (code != 0) {
69
+ if (code != 0 && options.throwOnError) {
65
70
  // assuming last log is the error message before exiting
66
71
  rejectFunc(errorLogs.slice(-3).join("\n"));
67
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"run-all-tests.d.ts","sourceRoot":"","sources":["../../src/lib/run-all-tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAQ5D,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,eAAe,EACf,cAAc,EACd,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,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,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,GAAG,YAAY,CAmBf"}
1
+ {"version":3,"file":"run-all-tests.d.ts","sourceRoot":"","sources":["../../src/lib/run-all-tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAQ5D,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,eAAe,EACf,cAAc,EACd,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,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,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,GAAG,YAAY,CAyBf"}
@@ -16,6 +16,10 @@ function runAllTestsCmd({ projects, passthroughArgs, patternsToGrep, filesFilter
16
16
  .join(" ");
17
17
  let args = ` ${filesFilter || ""} ${grepArgs} ${projectsArg} ${passthroughArgs || ""}`;
18
18
  const env = Object.assign({ ...process.env, PW_TEST_HTML_REPORT_OPEN: "never" }, envOverrides);
19
+ if (process.env.RUN_PLAYWRIGHT_HEADED &&
20
+ process.env.RUN_PLAYWRIGHT_HEADED === "true") {
21
+ args = `${args} --headed`;
22
+ }
19
23
  const testRunCmd = normalizeSpaces(`npx ${testRunner} test ${args}`);
20
24
  return {
21
25
  ...(0, cmd_1.getCommandFromString)(testRunCmd),
@@ -1,10 +1,11 @@
1
1
  import { CommandToRun, Platform, TestCase } from "../types";
2
- export declare function runSpecificTestsCmd({ tests, projects, passthroughArgs, platform, envOverrides, }: {
2
+ export declare function runSpecificTestsCmd({ tests, projects, passthroughArgs, platform, envOverrides, repoDir, }: {
3
3
  tests?: TestCase[];
4
4
  projects: string[];
5
5
  passthroughArgs?: string;
6
6
  platform: Platform;
7
7
  filesFilter?: string;
8
8
  envOverrides?: Record<string, string>;
9
+ repoDir: string;
9
10
  }): Promise<CommandToRun>;
10
11
  //# sourceMappingURL=run-specific-test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-specific-test.d.ts","sourceRoot":"","sources":["../../src/lib/run-specific-test.ts"],"names":[],"mappings":"AAAA,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,GACb,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;CACvC,GAAG,OAAO,CAAC,YAAY,CAAC,CAiFxB"}
1
+ {"version":3,"file":"run-specific-test.d.ts","sourceRoot":"","sources":["../../src/lib/run-specific-test.ts"],"names":[],"mappings":"AAAA,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,CAuFxB"}
@@ -3,13 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runSpecificTestsCmd = runSpecificTestsCmd;
4
4
  const utils_1 = require("../utils");
5
5
  const run_all_tests_1 = require("./run-all-tests");
6
- async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, platform, envOverrides, }) {
6
+ async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, platform, envOverrides, repoDir, }) {
7
7
  if (!tests || tests.length === 0) {
8
8
  throw new Error("No tests found");
9
9
  }
10
10
  let patternsToGrep = [];
11
11
  let filesToRun = [];
12
12
  for (const testCase of tests) {
13
+ // TODO: Why do we have this getAllFilePaths call?
14
+ // TODO: Can we remove `dir` from the test case entity?
13
15
  const files = await (0, utils_1.getAllFilePaths)(testCase.dir, {
14
16
  filePath: testCase.filePath,
15
17
  });
@@ -55,7 +57,7 @@ async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, plat
55
57
  }
56
58
  }
57
59
  }
58
- const teardownLabels = await (0, utils_1.labelTeardownProjects)(projects, platform);
60
+ const teardownLabels = await (0, utils_1.labelTeardownProjects)(projects, platform, repoDir);
59
61
  const isRunningForTeardownProjectOnly = teardownLabels && teardownLabels.every((label) => label.isTeardown);
60
62
  if (isRunningForTeardownProjectOnly) {
61
63
  // To run teardown projects, we need to run the `setup` project first, and playwright runs
@@ -6,6 +6,6 @@ type PlaywrightProject = {
6
6
  testIgnore: string[] | string | undefined;
7
7
  teardown: string | undefined;
8
8
  };
9
- export declare function getProjectsFromPlaywrightConfig(platform: Platform): Promise<PlaywrightProject[]>;
9
+ export declare function getProjectsFromPlaywrightConfig(platform: Platform, repoDir: string): Promise<PlaywrightProject[]>;
10
10
  export {};
11
11
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAKA,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,GACjB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAqC9B"}
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,CA8B9B"}
@@ -4,40 +4,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getProjectsFromPlaywrightConfig = getProjectsFromPlaywrightConfig;
7
+ const child_process_1 = require("child_process");
8
+ const fs_1 = __importDefault(require("fs"));
7
9
  const path_1 = __importDefault(require("path"));
8
- // For TypeScript type safety
9
- let tsxImport = null;
10
10
  const types_1 = require("../types");
11
- async function getProjectsFromPlaywrightConfig(platform) {
11
+ async function getProjectsFromPlaywrightConfig(platform, repoDir) {
12
12
  const configName = platform === types_1.Platform.WEB ? "playwright.config.ts" : "appwright.config.ts";
13
- const directoryPath = ".";
14
- const pwFile = path_1.default.resolve(directoryPath, configName);
15
- if (typeof window !== "undefined") {
16
- throw new Error("readPlaywrightConfig cannot be used in browser environments");
17
- }
18
- else {
19
- // Only initialize on server side
20
- // This will only execute on the server
21
- await import("tsx/cjs/api")
22
- .then((module) => {
23
- tsxImport = module;
24
- })
25
- .catch(() => {
26
- console.warn("Failed to import tsx: --->");
27
- });
28
- }
29
- if (!tsxImport) {
30
- console.warn("tsx module not available");
31
- return [];
32
- }
33
- const repoDir = process.cwd();
34
- const [lastDir] = repoDir.split("/").reverse();
35
13
  try {
36
- const playwrightConfig = (await tsxImport.require(pwFile, `${repoDir}/${lastDir}`)).default;
37
- return playwrightConfig.projects;
14
+ const configPath = path_1.default.join(repoDir, configName);
15
+ const tmpScriptPath = path_1.default.resolve(__dirname, "temp-extract-projects.js");
16
+ fs_1.default.writeFileSync(tmpScriptPath, `
17
+ // Import the config directly with the full path
18
+ const configModule = require('${configPath.replace(/\\/g, "\\\\")}');
19
+ const projects = configModule.default.projects;
20
+ console.log(JSON.stringify(projects));
21
+ `);
22
+ const result = (0, child_process_1.execSync)(`npx -y ts-node ${tmpScriptPath}`, {
23
+ encoding: "utf8",
24
+ env: {
25
+ ...process.env,
26
+ TS_NODE_PROJECT: path_1.default.join(repoDir, "tsconfig.json"),
27
+ NODE_PATH: path_1.default.join(repoDir, "node_modules"),
28
+ },
29
+ });
30
+ fs_1.default.unlinkSync(tmpScriptPath);
31
+ const projects = JSON.parse(result);
32
+ return projects;
38
33
  }
39
- catch (err) {
40
- console.error("Error getting project list from playwright config", err);
34
+ catch (error) {
35
+ console.error("Error extracting Playwright projects:", error);
41
36
  }
42
37
  return [];
43
38
  }
@@ -27,13 +27,14 @@ export declare function markTestAsOnly({ sourceFile, parentDescribeNode, testCas
27
27
  filePath: string;
28
28
  }): Promise<void>;
29
29
  export declare const filterArrayByGlobMatchersSet: (input: string[], globMatcherSets: string[][]) => string[];
30
- export declare function labelTeardownProjects(projectNames: string[], platform: Platform): Promise<{
30
+ export declare function labelTeardownProjects(projectNames: string[], platform: Platform, repoDir: string): Promise<{
31
31
  isTeardown: boolean;
32
32
  correspondingSetupProject: string | undefined;
33
33
  }[]>;
34
- export declare const generateProjectFilters: ({ platform, filteringSets, }: {
34
+ export declare const generateProjectFilters: ({ platform, filteringSets, repoDir, }: {
35
35
  platform: Platform;
36
36
  filteringSets: string[];
37
+ repoDir: string;
37
38
  }) => Promise<string[]>;
38
39
  export declare function buildRepoName(projectName: string): string;
39
40
  export declare const pickNameFromPackageJson: () => Promise<string | 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,GAAE,MAAgB,EAC/B,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAClC,OAAO,CAAC,MAAM,EAAE,CAAC,CA4BnB;AAED,eAAO,MAAM,gCAAgC,GAC3C,YAAY,UAAU,KACrB,MAgBF,CAAC;AAEF,wBAAsB,eAAe,CAAC,EACpC,QAAQ,EACR,YAAY,EACZ,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,GAAG,OAAO,CAAC;IAAE,YAAY,EAAE,IAAI,GAAG,SAAS,CAAC;IAAC,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Aa,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,KAAG,OAAO,CAAC,MAAM,EAAE,CAgBnB,CAAC;AAEF,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,eAAO,MAAM,uBAAuB,QAAa,OAAO,CACtD,MAAM,GAAG,SAAS,CAMnB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,CAclE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,UAAU,QAAQ,KAAG,aAIlD,CAAC;AA4DF,eAAO,MAAM,sBAAsB,GAAU,WAAW,MAAM,kBAkB7D,CAAC;AA0BF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,YAAY,EACZ,MAAM,EACN,OAAO,GACR,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,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,CA8CA"}
@@ -179,8 +179,8 @@ globMatcherSets) => {
179
179
  return filteredList;
180
180
  };
181
181
  exports.filterArrayByGlobMatchersSet = filterArrayByGlobMatchersSet;
182
- async function labelTeardownProjects(projectNames, platform) {
183
- const allProjects = await (0, config_1.getProjectsFromPlaywrightConfig)(platform);
182
+ async function labelTeardownProjects(projectNames, platform, repoDir) {
183
+ const allProjects = await (0, config_1.getProjectsFromPlaywrightConfig)(platform, repoDir);
184
184
  return projectNames.map((projectName) => {
185
185
  const setupForTeardown = allProjects.find((p) => p.teardown === projectName);
186
186
  if (setupForTeardown) {
@@ -197,8 +197,8 @@ async function labelTeardownProjects(projectNames, platform) {
197
197
  }
198
198
  });
199
199
  }
200
- const generateProjectFilters = async ({ platform, filteringSets, }) => {
201
- const allProjects = await (0, config_1.getProjectsFromPlaywrightConfig)(platform);
200
+ const generateProjectFilters = async ({ platform, filteringSets, repoDir, }) => {
201
+ const allProjects = await (0, config_1.getProjectsFromPlaywrightConfig)(platform, repoDir);
202
202
  const allProjectNames = allProjects.map((project) => project.name);
203
203
  const filters = filteringSets.map((matchingString) => matchingString.split(","));
204
204
  const filteredProjects = (0, exports.filterArrayByGlobMatchersSet)(allProjectNames, filters);
@@ -226,7 +226,10 @@ const downloadBuild = async (buildUrl) => {
226
226
  if (buildDownloadScript && buildUrl) {
227
227
  console.log(`Downloading build from ${buildUrl}`);
228
228
  await (0, cmd_1.spawnCmd)(`npm`, ["run", "download", buildUrl], {
229
- env: { ...Object(process.env) },
229
+ cwd: process.cwd(),
230
+ envOverrides: {},
231
+ captureOutput: false,
232
+ throwOnError: true,
230
233
  });
231
234
  }
232
235
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-run",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -19,8 +19,7 @@
19
19
  "commander": "^12.1.0",
20
20
  "dotenv": "^16.4.5",
21
21
  "minimatch": "^10.0.1",
22
- "ts-morph": "^23.0.0",
23
- "tsx": "^4.16.2"
22
+ "ts-morph": "^23.0.0"
24
23
  },
25
24
  "devDependencies": {
26
25
  "@types/async-retry": "^1.4.8",