@empiricalrun/test-run 0.2.0 → 0.3.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @empiricalrun/test-run
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7a2606c: feat: make call to dashboard to fetch environment detail inside test-run
8
+
9
+ ## 0.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 7ea52ce: fix: set default value of options.project
14
+
3
15
  ## 0.2.0
4
16
 
5
17
  ### Minor Changes
package/dist/bin/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const commander_1 = require("commander");
5
5
  const __1 = require("..");
6
+ const dashboard_1 = require("../dashboard");
6
7
  const utils_1 = require("../utils");
7
8
  (async function main() {
8
9
  // TODO: add support for suites
@@ -19,6 +20,7 @@ const utils_1 = require("../utils");
19
20
  console.error("--name and --forbid-only options cannot be used together");
20
21
  process.exit(1);
21
22
  }
23
+ options.project = options.project || ["*"];
22
24
  const optionsToStrip = [
23
25
  "-n",
24
26
  "--name",
@@ -34,7 +36,15 @@ const utils_1 = require("../utils");
34
36
  .slice(2)
35
37
  .filter((arg) => !optionsToStrip.includes(arg));
36
38
  try {
37
- const projectFilters = await (0, utils_1.generateProjectFilters)(options.project);
39
+ let environmentSpecificProjects = [];
40
+ if (process.env.TEST_RUN_ENVIRONMENT) {
41
+ const environmentDetail = await (0, dashboard_1.fetchEnvironment)();
42
+ environmentSpecificProjects = environmentDetail.playwright_projects;
43
+ }
44
+ const projectFilters = await (0, utils_1.generateProjectFilters)([
45
+ ...options.project,
46
+ ...environmentSpecificProjects,
47
+ ]);
38
48
  pwOptions.push(...projectFilters);
39
49
  const { hasTestPassed } = await (0, __1.runTest)({
40
50
  name: options.name,
@@ -0,0 +1,3 @@
1
+ import { Environment } from "./types";
2
+ export declare const fetchEnvironment: () => Promise<Environment>;
3
+ //# sourceMappingURL=dashboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAKtC,eAAO,MAAM,gBAAgB,QAAa,QAAQ,WAAW,CA0B5D,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchEnvironment = void 0;
4
+ const utils_1 = require("./utils");
5
+ const DOMAIN = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
6
+ const fetchEnvironment = async () => {
7
+ const projectRepo = (0, utils_1.buildRepoName)(process.env.PROJECT_NAME);
8
+ const environmentSlug = `${process.env.TEST_RUN_ENVIRONMENT}`;
9
+ const resp = await fetch(`${DOMAIN}/api/environments?project_repo_name=${projectRepo}&environment_slug=${environmentSlug}`, {
10
+ method: "GET",
11
+ headers: {
12
+ "Content-Type": "application/json",
13
+ Authorization: `weQPMWKT`,
14
+ },
15
+ });
16
+ if (!resp.ok) {
17
+ throw new Error(`Failed to fetch environment details from dashboard`);
18
+ }
19
+ const data = (await resp.json());
20
+ return data.data.environment;
21
+ };
22
+ exports.fetchEnvironment = fetchEnvironment;
@@ -3,4 +3,10 @@ export type TestRunParameters = {
3
3
  dir?: string;
4
4
  pwOptions?: string;
5
5
  };
6
+ export type Environment = {
7
+ id: number;
8
+ project_id: number;
9
+ slug: string;
10
+ playwright_projects: string[];
11
+ };
6
12
  //# 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"}
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"}
@@ -31,4 +31,5 @@ export declare function markTestAsOnly({ sourceFile, parentDescribeNode, testCas
31
31
  export declare function getProjectsFromPlaywrightConfig(): Promise<string[]>;
32
32
  export declare const filterArrayByGlobMatchersSet: (input: string[], globMatcherSets: string[][]) => string[];
33
33
  export declare const generateProjectFilters: (filteringSets: string[]) => Promise<string[]>;
34
+ export declare function buildRepoName(projectName: string): string;
34
35
  //# 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;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mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateProjectFilters = exports.filterArrayByGlobMatchersSet = exports.getProjectsFromPlaywrightConfig = exports.markTestAsOnly = exports.hasTopLevelDescribeConfigureWithSerialMode = exports.findFirstSerialDescribeBlock = exports.hasTestBlock = exports.getTestCaseNode = exports.getAllFilePaths = exports.cmd = void 0;
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;
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");
@@ -197,3 +197,7 @@ const generateProjectFilters = async (filteringSets) => {
197
197
  return filteredProjects.map((projectName) => `--project ${projectName}`);
198
198
  };
199
199
  exports.generateProjectFilters = generateProjectFilters;
200
+ function buildRepoName(projectName) {
201
+ return `${projectName}-tests`;
202
+ }
203
+ exports.buildRepoName = buildRepoName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-run",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"