mirror of
https://github.com/balkian/CORE19-01_git_cli.git
synced 2024-11-01 01:21:43 +00:00
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
|
/*
|
||
|
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}`);
|
||
|
});
|