@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 +6 -0
- package/dist/bin/index.js +14 -5
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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<
|
|
7
|
+
export declare function runTest({ name, dir, pwOptions, }: TestRunParameters): Promise<{
|
|
8
|
+
hasTestPassed: boolean;
|
|
9
|
+
}>;
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
58
|
+
return {
|
|
59
|
+
hasTestPassed,
|
|
60
|
+
};
|
|
62
61
|
}
|
|
63
62
|
exports.runTest = runTest;
|