refactoring of es6 test skeleton

This commit is contained in:
zadam
2020-06-03 17:28:57 +02:00
parent 99120be46d
commit 01a7af965c
4 changed files with 21 additions and 95 deletions

41
spec-es6/mini_test.js Normal file
View File

@@ -0,0 +1,41 @@
export function describe(name, cb) {
console.log(`Running ${name}`);
cb();
}
export async function it(name, cb) {
console.log(` Running ${name}`);
cb();
}
let errorCount = 0;
export function expect(val) {
return {
toEqual: comparedVal => {
const jsonVal = JSON.stringify(val);
const comparedJsonVal = JSON.stringify(comparedVal);
if (jsonVal !== comparedJsonVal) {
console.trace("toEqual check failed.");
console.error(`expected: ${comparedJsonVal}`);
console.error(`got: ${jsonVal}`);
errorCount++;
}
}
}
}
export function execute() {
console.log("");
if (errorCount) {
console.log(`!!!${errorCount} tests failed!!!`);
}
else {
console.log("All tests passed!");
}
}