@empiricalrun/test-run 0.1.0 → 0.1.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,11 @@
1
1
  # @empiricalrun/test-run
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - cb2ec31: fix: test-run marking failed tests as pass
8
+
3
9
  ## 0.1.0
4
10
 
5
11
  ### Minor Changes
package/dist/bin/index.js CHANGED
@@ -31,9 +31,18 @@ const __1 = require("..");
31
31
  console.error("forbid-only option is not supported");
32
32
  process.exit(1);
33
33
  }
34
- await (0, __1.runTest)({
35
- name: options.name,
36
- dir: options.dir || "tests",
37
- pwOptions: pwOptions.join(" "),
38
- });
34
+ try {
35
+ const { hasTestPassed } = await (0, __1.runTest)({
36
+ name: options.name,
37
+ dir: options.dir || "tests",
38
+ pwOptions: pwOptions.join(" "),
39
+ });
40
+ if (!hasTestPassed) {
41
+ process.exit(1);
42
+ }
43
+ }
44
+ catch (error) {
45
+ console.error("Error while running playwright test:", error.message);
46
+ process.exit(1);
47
+ }
39
48
  })();
package/dist/index.d.ts CHANGED
@@ -4,5 +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<void>;
7
+ export declare function runTest({ name, dir, pwOptions, }: TestRunParameters): Promise<{
8
+ hasTestPassed: boolean;
9
+ }>;
8
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;AAW5C;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,iBAAiB,iBAoDxE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAW5C;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,EAC5B,IAAI,EACJ,GAAG,EACH,SAAS,GACV,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CAmDD"}
package/dist/index.js CHANGED
@@ -11,8 +11,7 @@ const utils_1 = require("./utils");
11
11
  * @export
12
12
  * @param {TestRunParameters} { name, dir, pwOptions }
13
13
  */
14
- async function runTest({ name, dir, pwOptions }) {
15
- console.log("getting all files in directory:", dir);
14
+ async function runTest({ name, dir, pwOptions, }) {
16
15
  const files = await (0, utils_1.getAllFilePaths)(dir);
17
16
  let matchingFilePath = "";
18
17
  // find the first file that contains the test block
@@ -25,8 +24,8 @@ async function runTest({ name, dir, pwOptions }) {
25
24
  }
26
25
  }
27
26
  if (!matchingFilePath) {
28
- console.error("No test block found for the given test name");
29
- return;
27
+ const message = `No test block found for the given test name: ${name}`;
28
+ throw Error(message);
30
29
  }
31
30
  const testNode = await (0, utils_1.getTestCaseNode)({
32
31
  filePath: matchingFilePath,
@@ -42,6 +41,7 @@ async function runTest({ name, dir, pwOptions }) {
42
41
  if (!isFileMarkedSerial) {
43
42
  await (0, utils_1.markTestAsOnly)(matchingFilePath, testNode.getText(), parentDescribe?.getText() || "");
44
43
  }
44
+ let hasTestPassed = true;
45
45
  try {
46
46
  const env = Object({ ...process.env });
47
47
  const pwRunCmd = `npx playwright test ${matchingFilePath} ${pwOptions}`;
@@ -51,13 +51,12 @@ async function runTest({ name, dir, pwOptions }) {
51
51
  });
52
52
  }
53
53
  catch (e) {
54
- console.error("Error executing playwright test", e);
54
+ hasTestPassed = false;
55
55
  }
56
56
  // revert the changes made to the file to mark tests as only
57
57
  await fs_extra_1.default.writeFile(matchingFilePath, currentFileContent);
58
- if (!matchingFilePath) {
59
- console.error("No test block found for the given test name");
60
- return;
61
- }
58
+ return {
59
+ hasTestPassed,
60
+ };
62
61
  }
63
62
  exports.runTest = runTest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-run",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"