mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-07 17:01:23 +08:00
improve the test with a single command only "npm test"
This commit is contained in:
@@ -5,6 +5,7 @@ const { debug } = require("../src/util");
|
||||
const passwordHash = require("./password-hash");
|
||||
const dayjs = require("dayjs");
|
||||
const { Resolver } = require("dns");
|
||||
const child_process = require("child_process");
|
||||
|
||||
/**
|
||||
* Init or reset JWT secret
|
||||
@@ -292,3 +293,22 @@ exports.checkLogin = (socket) => {
|
||||
throw new Error("You are not logged in.");
|
||||
}
|
||||
};
|
||||
|
||||
exports.startUnitTest = async () => {
|
||||
console.log("Starting unit test...");
|
||||
const npm = /^win/.test(process.platform) ? "npm.cmd" : "npm";
|
||||
const child = child_process.spawn(npm, ["run", "jest"]);
|
||||
|
||||
child.stdout.on("data", (data) => {
|
||||
console.log(data.toString());
|
||||
});
|
||||
|
||||
child.stderr.on("data", (data) => {
|
||||
console.log(data.toString());
|
||||
});
|
||||
|
||||
child.on("close", function (code) {
|
||||
console.log("Jest exit code: " + code);
|
||||
process.kill(process.pid, "SIGINT");
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user