Search code examples
testingautomationautomated-testse2e-testingtestcafe

Does Testcafe retry assertions with Selector.count and Selector.exists?


In testcafe documentation I found that assertions with count and exists "execute immediately regardless of the selector timeout". However in wait-mechanism-for-assertions paragraph documentation states that "TestCafe keeps recalculating the actual value until it matches the expected value or the assertion timeout passes".

So, do assertions with exists execute immediately or use the default "assertion timeout" (3000ms)?


Solution

  • There is a difference between Selector Timeout and Asseertion Timeout.

    Selector Timeout specifies the time (in milliseconds) within which selectors attempt to return a node. Assertion Timeout specifies the amount of time (in milliseconds) TestCafe attempts to successfully execute an assertion.

    For the exists and count property, the Selector Timeout will be ignored:

    // NOTE: there is no timeout here
    console.log(await Selector('non-existing-element').count)
    

    However, the Assertion Timeout will be applied:

    // NOTE: there is a timeout
    await t.expect(Selector('non-existing-element').count).eql(100)