Search code examples
javascriptautomated-testse2e-testingweb-testingtestcafe

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'


Solution

  • 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);