@empiricalrun/test-run 0.7.5 → 0.7.6
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,9 +1,4 @@
|
|
|
1
1
|
import { TestRunParameters } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @param {TestRunParameters} { name, dir, pwOptions }
|
|
6
|
-
*/
|
|
7
2
|
export declare function runSpecificTests({ tests, projects, pwOptions, platform, }: TestRunParameters): Promise<{
|
|
8
3
|
hasTestPassed: boolean;
|
|
9
4
|
}>;
|
|
@@ -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;
|
|
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,GACT,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CAuFD"}
|
|
@@ -7,11 +7,13 @@ exports.runSpecificTests = void 0;
|
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
function setupProcessListeners(cleanup) {
|
|
11
|
+
const events = ["beforeExit", "exit", "SIGINT", "SIGTERM"];
|
|
12
|
+
events.forEach((event) => process.on(event, cleanup));
|
|
13
|
+
return () => {
|
|
14
|
+
events.forEach((event) => process.removeListener(event, cleanup));
|
|
15
|
+
};
|
|
16
|
+
}
|
|
15
17
|
async function runSpecificTests({ tests = [], projects, pwOptions, platform, }) {
|
|
16
18
|
if (!tests || tests.length === 0) {
|
|
17
19
|
throw new Error("No tests found");
|
|
@@ -72,11 +74,7 @@ async function runSpecificTests({ tests = [], projects, pwOptions, platform, })
|
|
|
72
74
|
});
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
|
|
76
|
-
process.on("beforeExit", revertFileContent);
|
|
77
|
-
process.on("exit", revertFileContent);
|
|
78
|
-
process.on("SIGINT", revertFileContent);
|
|
79
|
-
process.on("SIGTERM", revertFileContent);
|
|
77
|
+
const removeListeners = setupProcessListeners(revertFileContent);
|
|
80
78
|
let hasTestPassed = true;
|
|
81
79
|
try {
|
|
82
80
|
const testRunner = (0, utils_1.getTestRunner)(platform);
|
|
@@ -91,6 +89,7 @@ async function runSpecificTests({ tests = [], projects, pwOptions, platform, })
|
|
|
91
89
|
catch (e) {
|
|
92
90
|
hasTestPassed = false;
|
|
93
91
|
}
|
|
92
|
+
removeListeners();
|
|
94
93
|
revertFileContent();
|
|
95
94
|
return {
|
|
96
95
|
hasTestPassed,
|