D.Rooij
D.Rooij

Reputation: 253

Output all failures instead of one in TestCafe

How can i display all failures when running tests.

test('test case', async (t) => ){
   await t.expect(1).eql(2);
   await t.expect(3).eql(4);
}

What i get (first failure, then stops):

1) AssertionError: expected '1' to deeply equal '2'

What i want (all wrong data):

1) AssertionError: expected '1' to deeply equal '2'

1) AssertionError: expected '3' to deeply equal '4'

Upvotes: 2

Views: 206

Answers (2)

D.Rooij
D.Rooij

Reputation: 253

Awesome, this works. Thanks for the tip Stiks ;)

let x = 0;

for (let i in result1){
    if (result1[i] != result2[i]){
        x += 1;
        console.log( x +') AssertionError: expected ' + result1[i] + ' to deeply equal ' + result2[i] );
    }
}
await t.expect(x).eql(0);

Upvotes: 2

Stiks
Stiks

Reputation: 221

This will work, just put all elements in array and iterate trough them

for(let i = 0; i < 400; i++) {
    test
    (`Test `+i, async t => {
        await t.expect(i).eql(i+1);
    });
}

Upvotes: 4

Related Questions