1
0
mirror of https://github.com/balkian/CORE19-01_git_cli.git synced 2024-11-01 01:21:43 +00:00
CORE19-01_git_cli/tests/launcher.js

40 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-01-28 19:22:55 +00:00
/*
Checker launcher
*/
const Mocha = require("mocha");
const assignment_path = "./tests/checks.test.js";
let score = 0;
let score_total = 0;
new Mocha({
timeout: 60 * 1000,
reporter: function () {
}
})
.addFile(assignment_path)
.run()
.on('pass', function (test) {
score += test.ctx.score;
score_total += test.ctx.score;
process.stdout.write(
`\nTest: ${test.ctx.name}
Score: ${test.ctx.score}/${test.ctx.score}
Remarks: ${test.ctx.msg_ok}\n`
);
})
.on('fail', function (test, err) {
if ((test.title !== '"after all" hook') && (test.title !== '"before all" hook')) {
score_total += test.ctx.score;
process.stdout.write(
`\nTest: ${test.ctx.name}
Score: 0/${test.ctx.score}
Remarks: ${test.ctx.msg_err}\n`);
} else {
console.error("Launcher Error: " + err);
}
})
.on('end', function (test) {
process.stdout.write(`Final Result: ${score}/${score_total}`);
});