@empiricalrun/test-run 0.8.4 → 0.8.5

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,11 @@
1
1
  # @empiricalrun/test-run
2
2
 
3
+ ## 0.8.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 0634233: fix: run setup projects when test-run tool call has teardown project
8
+
3
9
  ## 0.8.4
4
10
 
5
11
  ### Patch Changes
@@ -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;AAK7C,eAAO,MAAM,wBAAwB,gBACtB,MAAM,mBACF,MAAM,KACtB,QAAQ;IACT,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;CACd,CAuDA,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;AAK7C,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"}
package/dist/dashboard.js CHANGED
@@ -33,7 +33,7 @@ const fetchEnvironmentAndBuild = async (projectName, environmentSlug) => {
33
33
  }, {
34
34
  retries: 3,
35
35
  minTimeout: 1000,
36
- maxTimeout: 60000,
36
+ maxTimeout: 60_000,
37
37
  factor: 3,
38
38
  });
39
39
  if (!data?.data) {
package/dist/index.js CHANGED
@@ -3,7 +3,8 @@ 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.listAllTests = exports.runSingleTest = void 0;
6
+ exports.runSingleTest = runSingleTest;
7
+ exports.listAllTests = listAllTests;
7
8
  const promises_1 = __importDefault(require("fs/promises"));
8
9
  const path_1 = __importDefault(require("path"));
9
10
  const run_specific_test_1 = require("./lib/run-specific-test");
@@ -30,7 +31,6 @@ async function runSingleTest({ testName, suites, fileName, projects, envOverride
30
31
  summaryJson,
31
32
  };
32
33
  }
33
- exports.runSingleTest = runSingleTest;
34
34
  async function listAllTests(cwd) {
35
35
  const testRunner = (0, utils_1.getTestRunner)(types_1.Platform.WEB);
36
36
  const env = Object({ ...process.env });
@@ -73,4 +73,3 @@ async function listAllTests(cwd) {
73
73
  });
74
74
  return result;
75
75
  }
76
- exports.listAllTests = listAllTests;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runAllTests = void 0;
3
+ exports.runAllTests = runAllTests;
4
4
  const utils_1 = require("../utils");
5
5
  async function runAllTests({ projects, pwOptions, filesFilter, envOverrides, platform, }) {
6
6
  let hasTestPassed = true;
@@ -21,4 +21,3 @@ async function runAllTests({ projects, pwOptions, filesFilter, envOverrides, pla
21
21
  hasTestPassed,
22
22
  };
23
23
  }
24
- exports.runAllTests = runAllTests;
@@ -1 +1 @@
1
- {"version":3,"file":"run-specific-test.d.ts","sourceRoot":"","sources":["../../src/lib/run-specific-test.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAmB7C,wBAAsB,gBAAgB,CAAC,EACrC,KAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,YAAY,GACb,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CA+ED"}
1
+ {"version":3,"file":"run-specific-test.d.ts","sourceRoot":"","sources":["../../src/lib/run-specific-test.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAoB7C,wBAAsB,gBAAgB,CAAC,EACrC,KAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,YAAY,GACb,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CA+FD"}
@@ -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.runSpecificTests = void 0;
6
+ exports.runSpecificTests = runSpecificTests;
7
7
  const fs_1 = require("fs");
8
8
  const promises_1 = __importDefault(require("fs/promises"));
9
9
  const utils_1 = require("../utils");
@@ -19,6 +19,19 @@ async function runSpecificTests({ tests = [], projects, pwOptions, platform, env
19
19
  if (!tests || tests.length === 0) {
20
20
  throw new Error("No tests found");
21
21
  }
22
+ let disableTestOnlyMarking = false;
23
+ const teardownLabels = await (0, utils_1.labelTeardownProjects)(projects, platform);
24
+ const isRunningForTeardownProjectOnly = teardownLabels && teardownLabels.every((label) => label.isTeardown);
25
+ if (isRunningForTeardownProjectOnly) {
26
+ // To run teardown projects, we need to run the `setup` project first, and playwright runs
27
+ // teardown automatically, when the corresponding setup project is run.
28
+ // We also disable marking files with test.only, because we want all of the setup to run
29
+ // before running the teardown tests.
30
+ disableTestOnlyMarking = true;
31
+ projects = teardownLabels
32
+ .map((label) => label.correspondingSetupProject)
33
+ .filter((project) => project !== undefined);
34
+ }
22
35
  const touchedFiles = {};
23
36
  // revert the changes made to the file to mark tests as only
24
37
  // these needs to handle by listening to process exit/kill events
@@ -66,7 +79,7 @@ async function runSpecificTests({ tests = [], projects, pwOptions, platform, env
66
79
  touchedFiles[matchingFilePath] = currentFileContent;
67
80
  }
68
81
  // if the file is not marked serial, we need to mark the test or describe block as only
69
- if (!isFileMarkedSerial && testCaseNode) {
82
+ if (!isFileMarkedSerial && testCaseNode && !disableTestOnlyMarking) {
70
83
  await (0, utils_1.markTestAsOnly)({
71
84
  sourceFile,
72
85
  parentDescribeNode: parentDescribe,
@@ -87,4 +100,3 @@ async function runSpecificTests({ tests = [], projects, pwOptions, platform, env
87
100
  revertFileContent();
88
101
  return result;
89
102
  }
90
- exports.runSpecificTests = runSpecificTests;
@@ -3,7 +3,9 @@ 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.buildConfigFromCliArgs = exports.parseToken = exports.parseRcConfig = void 0;
6
+ exports.parseRcConfig = parseRcConfig;
7
+ exports.parseToken = parseToken;
8
+ exports.buildConfigFromCliArgs = buildConfigFromCliArgs;
7
9
  const fs_1 = require("fs");
8
10
  const promises_1 = __importDefault(require("fs/promises"));
9
11
  async function parseRcConfig() {
@@ -22,7 +24,6 @@ async function parseRcConfig() {
22
24
  }
23
25
  return undefined;
24
26
  }
25
- exports.parseRcConfig = parseRcConfig;
26
27
  function parseToken(token) {
27
28
  if (!token) {
28
29
  return undefined;
@@ -39,6 +40,4 @@ function parseToken(token) {
39
40
  }
40
41
  return undefined;
41
42
  }
42
- exports.parseToken = parseToken;
43
43
  function buildConfigFromCliArgs() { }
44
- exports.buildConfigFromCliArgs = buildConfigFromCliArgs;
@@ -1,5 +1,12 @@
1
1
  import { Node, SourceFile } from "ts-morph";
2
2
  import { Platform, TestFramework } from "../types";
3
+ type PlaywrightProject = {
4
+ name: string;
5
+ use: any;
6
+ testMatch: string[] | string | undefined;
7
+ testIgnore: string[] | string | undefined;
8
+ teardown: string | undefined;
9
+ };
3
10
  export declare function cmd(command: string[], options: {
4
11
  env?: Record<string, string>;
5
12
  cwd?: string;
@@ -46,8 +53,12 @@ export declare function markTestAsOnly({ sourceFile, parentDescribeNode, testCas
46
53
  testCaseNode: Node;
47
54
  filePath: string;
48
55
  }): Promise<void>;
49
- export declare function getProjectsFromPlaywrightConfig(platform: Platform): Promise<any>;
56
+ export declare function getProjectsFromPlaywrightConfig(platform: Platform): Promise<PlaywrightProject[]>;
50
57
  export declare const filterArrayByGlobMatchersSet: (input: string[], globMatcherSets: string[][]) => string[];
58
+ export declare function labelTeardownProjects(projectNames: string[], platform: Platform): Promise<{
59
+ isTeardown: boolean;
60
+ correspondingSetupProject: string | undefined;
61
+ }[]>;
51
62
  export declare const generateProjectFilters: ({ platform, filteringSets, }: {
52
63
  platform: Platform;
53
64
  filteringSets: string[];
@@ -74,4 +85,5 @@ export declare function getTypescriptTestBlock({ scenarioName, suites, content,
74
85
  testAlias: string;
75
86
  sourceFile: SourceFile;
76
87
  };
88
+ export {};
77
89
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAW,UAAU,EAAc,MAAM,UAAU,CAAC;AAOjE,OAAO,EAEL,QAAQ,EAER,aAAa,EACd,MAAM,UAAU,CAAC;AA0ClB,wBAAsB,GAAG,CACvB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IACP,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GACA,OAAO,CAAC,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CA+CpD;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA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,MAAM,GAAG,SAAS,CAMnB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,CAWlE,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"}
@@ -3,7 +3,19 @@ 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.getTypescriptTestBlock = exports.handleTeardownSkipFlag = exports.getTestRunner = exports.downloadBuild = exports.pickNameFromPackageJson = exports.buildRepoName = exports.generateProjectFilters = exports.filterArrayByGlobMatchersSet = exports.getProjectsFromPlaywrightConfig = exports.markTestAsOnly = exports.hasTopLevelDescribeConfigureWithSerialMode = exports.findFirstSerialDescribeBlock = exports.hasTestBlock = exports.getTestCaseNode = exports.getTestModuleAliasFromSourceFile = exports.getAllFilePaths = exports.cmdWithOutput = exports.cmd = void 0;
6
+ exports.handleTeardownSkipFlag = exports.getTestRunner = exports.downloadBuild = exports.pickNameFromPackageJson = exports.generateProjectFilters = exports.filterArrayByGlobMatchersSet = exports.getTestModuleAliasFromSourceFile = void 0;
7
+ exports.cmd = cmd;
8
+ exports.cmdWithOutput = cmdWithOutput;
9
+ exports.getAllFilePaths = getAllFilePaths;
10
+ exports.getTestCaseNode = getTestCaseNode;
11
+ exports.hasTestBlock = hasTestBlock;
12
+ exports.findFirstSerialDescribeBlock = findFirstSerialDescribeBlock;
13
+ exports.hasTopLevelDescribeConfigureWithSerialMode = hasTopLevelDescribeConfigureWithSerialMode;
14
+ exports.markTestAsOnly = markTestAsOnly;
15
+ exports.getProjectsFromPlaywrightConfig = getProjectsFromPlaywrightConfig;
16
+ exports.labelTeardownProjects = labelTeardownProjects;
17
+ exports.buildRepoName = buildRepoName;
18
+ exports.getTypescriptTestBlock = getTypescriptTestBlock;
7
19
  const child_process_1 = require("child_process");
8
20
  const fs_1 = require("fs");
9
21
  const promises_1 = __importDefault(require("fs/promises"));
@@ -89,12 +101,10 @@ async function cmd(command, options) {
89
101
  });
90
102
  });
91
103
  }
92
- exports.cmd = cmd;
93
104
  async function cmdWithOutput(command, options) {
94
105
  const result = await cmd(command, { ...options, captureOutput: true });
95
106
  return result;
96
107
  }
97
- exports.cmdWithOutput = cmdWithOutput;
98
108
  /**
99
109
  *
100
110
  *
@@ -131,7 +141,6 @@ async function getAllFilePaths(directoryPath = "tests", filters = {}) {
131
141
  }
132
142
  return filePaths;
133
143
  }
134
- exports.getAllFilePaths = getAllFilePaths;
135
144
  const getTestModuleAliasFromSourceFile = (sourceFile) => {
136
145
  return (sourceFile
137
146
  .getImportDeclarations()
@@ -155,7 +164,6 @@ async function getTestCaseNode({ filePath, scenarioName, suites, }) {
155
164
  });
156
165
  return { testCaseNode: testNode, sourceFile };
157
166
  }
158
- exports.getTestCaseNode = getTestCaseNode;
159
167
  async function hasTestBlock({ filePath, scenarioName, suites, }) {
160
168
  const { testCaseNode } = await getTestCaseNode({
161
169
  filePath,
@@ -164,7 +172,6 @@ async function hasTestBlock({ filePath, scenarioName, suites, }) {
164
172
  });
165
173
  return !!testCaseNode;
166
174
  }
167
- exports.hasTestBlock = hasTestBlock;
168
175
  function findFirstSerialDescribeBlock(node) {
169
176
  let currentNode = node;
170
177
  // Traverse upwards until we find a 'describe' block with 'serial: true'
@@ -189,7 +196,6 @@ function findFirstSerialDescribeBlock(node) {
189
196
  }
190
197
  return undefined; // Return undefined if no 'describe' with serial: true is found
191
198
  }
192
- exports.findFirstSerialDescribeBlock = findFirstSerialDescribeBlock;
193
199
  async function hasTopLevelDescribeConfigureWithSerialMode(filePath) {
194
200
  const project = new ts_morph_1.Project();
195
201
  const content = await promises_1.default.readFile(filePath, "utf-8");
@@ -217,7 +223,6 @@ async function hasTopLevelDescribeConfigureWithSerialMode(filePath) {
217
223
  }
218
224
  return false;
219
225
  }
220
- exports.hasTopLevelDescribeConfigureWithSerialMode = hasTopLevelDescribeConfigureWithSerialMode;
221
226
  async function markTestAsOnly({ sourceFile, parentDescribeNode, testCaseNode, filePath, }) {
222
227
  let updatedTestFileContent = sourceFile.getFullText();
223
228
  if (!parentDescribeNode) {
@@ -236,7 +241,6 @@ async function markTestAsOnly({ sourceFile, parentDescribeNode, testCaseNode, fi
236
241
  }
237
242
  await promises_1.default.writeFile(filePath, updatedTestFileContent, "utf-8");
238
243
  }
239
- exports.markTestAsOnly = markTestAsOnly;
240
244
  async function getProjectsFromPlaywrightConfig(platform) {
241
245
  const configName = platform === types_1.Platform.WEB ? "playwright.config.ts" : "appwright.config.ts";
242
246
  const directoryPath = ".";
@@ -263,15 +267,13 @@ async function getProjectsFromPlaywrightConfig(platform) {
263
267
  const [lastDir] = repoDir.split("/").reverse();
264
268
  try {
265
269
  const playwrightConfig = (await tsxImport.require(pwFile, `${repoDir}/${lastDir}`)).default;
266
- const projectConfig = playwrightConfig.projects;
267
- return projectConfig.map((projectConfig) => projectConfig.name);
270
+ return playwrightConfig.projects;
268
271
  }
269
272
  catch (err) {
270
273
  console.error("Error getting project list from playwright config", err);
271
274
  }
272
275
  return [];
273
276
  }
274
- exports.getProjectsFromPlaywrightConfig = getProjectsFromPlaywrightConfig;
275
277
  const filterArrayByGlobMatchersSet = (
276
278
  // array that needs to be filtered
277
279
  input,
@@ -286,10 +288,29 @@ globMatcherSets) => {
286
288
  return filteredList;
287
289
  };
288
290
  exports.filterArrayByGlobMatchersSet = filterArrayByGlobMatchersSet;
291
+ async function labelTeardownProjects(projectNames, platform) {
292
+ const allProjects = await getProjectsFromPlaywrightConfig(platform);
293
+ return projectNames.map((projectName) => {
294
+ const setupForTeardown = allProjects.find((p) => p.teardown === projectName);
295
+ if (setupForTeardown) {
296
+ return {
297
+ isTeardown: true,
298
+ correspondingSetupProject: setupForTeardown.name,
299
+ };
300
+ }
301
+ else {
302
+ return {
303
+ isTeardown: false,
304
+ correspondingSetupProject: undefined,
305
+ };
306
+ }
307
+ });
308
+ }
289
309
  const generateProjectFilters = async ({ platform, filteringSets, }) => {
290
- const projectsDefinedInPwConfig = await getProjectsFromPlaywrightConfig(platform);
310
+ const allProjects = await getProjectsFromPlaywrightConfig(platform);
311
+ const allProjectNames = allProjects.map((project) => project.name);
291
312
  const filters = filteringSets.map((matchingString) => matchingString.split(","));
292
- const filteredProjects = (0, exports.filterArrayByGlobMatchersSet)(projectsDefinedInPwConfig, filters);
313
+ const filteredProjects = (0, exports.filterArrayByGlobMatchersSet)(allProjectNames, filters);
293
314
  if (filteredProjects.length === 0) {
294
315
  throw new Error("No projects found in playwright config that matches the filtering criteria");
295
316
  }
@@ -299,7 +320,6 @@ exports.generateProjectFilters = generateProjectFilters;
299
320
  function buildRepoName(projectName) {
300
321
  return `${projectName}-tests`;
301
322
  }
302
- exports.buildRepoName = buildRepoName;
303
323
  const pickNameFromPackageJson = async () => {
304
324
  const packageJSONPath = "package.json";
305
325
  const packageJsonStr = await promises_1.default.readFile(packageJSONPath, "utf-8");
@@ -459,4 +479,3 @@ function getTypescriptTestBlock({ scenarioName, suites, content, }) {
459
479
  sourceFile,
460
480
  };
461
481
  }
462
- exports.getTypescriptTestBlock = getTypescriptTestBlock;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-run",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -0,0 +1 @@
1
+ {"root":["./src/dashboard.ts","./src/index.ts","./src/bin/index.ts","./src/lib/run-all-tests.ts","./src/lib/run-specific-test.ts","./src/types/index.ts","./src/utils/config-parser.ts","./src/utils/index.ts"],"version":"5.8.3"}