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
Tags
No related merge requests found
...@@ -59,13 +59,14 @@ export function getTests(srcDir) { ...@@ -59,13 +59,14 @@ export function getTests(srcDir) {
return { only, all }; return { only, all };
} }
export function tryTest(test, refs, schema) { export function tryTest(nth, max, test, refs, schema) {
return _jsf.resolve(schema, refs).then(sample => { return _jsf.resolve(schema, refs).then(sample => {
if (test.dump) { if (test.dump) {
console.log(JSON.stringify(sample, null, 2)); console.log(JSON.stringify(sample, null, 2));
return; return;
} }
try {
if (test.type) { if (test.type) {
checkType(sample, test.type); checkType(sample, test.type);
} }
...@@ -73,6 +74,13 @@ export function tryTest(test, refs, schema) { ...@@ -73,6 +74,13 @@ export function tryTest(test, refs, schema) {
if (test.valid) { if (test.valid) {
checkSchema(sample, schema, refs); 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');
throw _e;
}
if (test.length) { if (test.length) {
expect(sample.length).to.eql(test.length); expect(sample.length).to.eql(test.length);
......
...@@ -54,13 +54,15 @@ function seed() { ...@@ -54,13 +54,15 @@ function seed() {
// support for "exhaustive" testing, increase or set in .json spec // support for "exhaustive" testing, increase or set in .json spec
// for detecting more bugs quickly by executing the same test N-times // 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 = []; const tasks = [];
while (nth) { while (nth) {
if (!test.skip) { if (!test.skip) {
tasks.push(tryTest(test, refs, schema)); tasks.push(tryTest(nth, max, test, refs, schema));
} }
nth -= 1; nth -= 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment