teslaTanch
teslaTanch

Reputation: 93

testcafe await t.expect with timeout is flaky

I have a scenario where I wait for element to not appear and once that happen I perform click action. what actual occur is that the click takes place although the expect for an element with timeout option isn't validate

await t.expect(StatusOnProgressIcon.exists).notOk('Unexistence of On progress status icon', { timeout: 120000 })
await t.click(someTab)

I would expect that the second line will execute only after the first line is asserted positive

Upvotes: 0

Views: 1465

Answers (2)

Alex Skorkin
Alex Skorkin

Reputation: 4274

My attempts to replicate this behavior were unsuccessful. The Smart Wait Mechanism for Assertions correctly waits until the assertion's actual value matches the expected value:

enter image description here

Here's my sample test case.

61609192.html

<!DOCTYPE html>
<head>
</head>
<body>
<p id="icon">Status Icon</p>
<button id="button" type="button">Add to cart</button>
</body>
<script>

setTimeout(() => {
    document.getElementById("icon").remove();
}, 8000);

</script>
</html>

61609192.js

import { Selector} from 'testcafe';

fixture('fixture')
    .page('./61609192.html');

test('test', async t => {

    const icon = Selector("#icon");
    const button = Selector("button");

    await t.expect(icon.exists).notOk('Icon does not exist', { timeout: 120000 })
    await t.click(button)

});

Please update my test case to illustrate the issue or provide your own test case where we can see the issue in action.

Upvotes: 2

VysakhMohan
VysakhMohan

Reputation: 567

Try

await t.expect(await StatusOnProgressIcon.exists).notOk('Unexistence of On progress status icon', { timeout: 120000 })

Upvotes: 1

Related Questions