mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 11:47:54 +01:00
ci: improve test runner script
This commit is contained in:
@@ -51,7 +51,6 @@
|
||||
"@types/hookrouter": "^2.2.5",
|
||||
"@types/node-fetch": "^2.5.10",
|
||||
"@types/quill": "^2.0.5",
|
||||
"find-process": "^1.4.4",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"chalk": "^4.1.0",
|
||||
"env-cmd": "^10.1.0",
|
||||
@@ -62,6 +61,7 @@
|
||||
"eslint-plugin-jsx-a11y": "^6.2.3",
|
||||
"eslint-plugin-react": "^7.22.0",
|
||||
"eslint-plugin-react-hooks": "^4.2.0",
|
||||
"find-process": "^1.4.4",
|
||||
"progress-bar-webpack-plugin": "^2.1.0",
|
||||
"source-map-explorer": "^2.5.2",
|
||||
"typescript": "^4.1.5",
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
const find = require("find-process");
|
||||
|
||||
const { p, u, f } = argv;
|
||||
const { p, updateSnapshots, file, noServer } = argv;
|
||||
|
||||
const args = [];
|
||||
if (u) args.push("-u");
|
||||
if (f) args.push(f);
|
||||
|
||||
const res = nothrow($`yarn debug -p ${p || 3000}`);
|
||||
res.stdout.on("data", async (data) => {
|
||||
const message = data.toString();
|
||||
if (
|
||||
message.includes("create a production build, use yarn build.") ||
|
||||
message.includes("Compiled with warnings")
|
||||
) {
|
||||
const testRes = await $`yarn playwright test ${args.join(" ")}`;
|
||||
await killServer();
|
||||
process.exit(testRes.exitCode);
|
||||
}
|
||||
});
|
||||
if (!noServer) {
|
||||
const res = nothrow($`yarn debug -p ${p || 3000}`);
|
||||
res.stdout.on("data", async (data) => {
|
||||
const message = data.toString();
|
||||
if (
|
||||
message.includes("create a production build, use yarn build.") ||
|
||||
message.includes("Compiled with warnings")
|
||||
) {
|
||||
const testRes = await startTestRunner();
|
||||
await killServer();
|
||||
process.exit(testRes.exitCode);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const testRes = await startTestRunner();
|
||||
process.exit(testRes.exitCode);
|
||||
}
|
||||
|
||||
async function killServer() {
|
||||
const nodeProcesses = await find("name", "node");
|
||||
@@ -28,3 +29,10 @@ async function killServer() {
|
||||
process.kill(rprocess.pid, "SIGINT");
|
||||
}
|
||||
}
|
||||
|
||||
async function startTestRunner() {
|
||||
if (!updateSnapshots && !file) return $`yarn playwright test`;
|
||||
else if (updateSnapshots && file) return $`yarn playwright test -u ${file}`;
|
||||
else if (file) return $`yarn playwright test ${file}`;
|
||||
else if (updateSnapshots) return $`yarn playwright test -u`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user