Skip to content
Snippets Groups Projects
Commit 1e147155 authored by Alvaro Cabrera Durán's avatar Alvaro Cabrera Durán
Browse files

Decorate ran tests on failure

parent dde60b47
Branches
No related tags found
No related merge requests found
......@@ -59,19 +59,27 @@ export function getTests(srcDir) {
return { only, all };
}
export function tryTest(test, refs, schema) {
export function tryTest(nth, max, test, refs, schema) {
return _jsf.resolve(schema, refs).then(sample => {
if (test.dump) {
console.log(JSON.stringify(sample, null, 2));
return;
}
if (test.type) {
checkType(sample, test.type);
}
try {
if (test.type) {
checkType(sample, test.type);
}
if (test.valid) {
checkSchema(sample, schema, refs);
}
} catch (e) {
const _e = new Error(`${e.message.split('\n')[0]} (${nth} of ${max})`);
_e.stack = e.stack.split('\n').slice(1).join('\n');
if (test.valid) {
checkSchema(sample, schema, refs);
throw _e;
}
if (test.length) {
......
......@@ -54,13 +54,15 @@ function seed() {
// support for "exhaustive" testing, increase or set in .json spec
// for detecting more bugs quickly by executing the same test N-times
let nth = test.repeat || (process.CI ? 100 : 10);
const max = test.repeat || (process.CI ? 100 : 10);
let nth = max;
const tasks = [];
while (nth) {
if (!test.skip) {
tasks.push(tryTest(test, refs, schema));
tasks.push(tryTest(nth, max, test, refs, schema));
}
nth -= 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment