Testcafe: Snapshot property warnings work incorrectly with helper functions

Created on 24 Aug 2020  路  7Comments  路  Source: DevExpress/testcafe

Using the example code from @Ogurecher I also get the warnings, despite them not being prefixed by await.

I am honestly baffled how a super hacky method like checking line numbers ever got merged. Not least because autoformatters such as Prettier will force the expect and selector to be on the same line in most cases. Adding a warning of this kind is fine but not with this implementation. I have made a hacky fix by putting my selectors on different lines for now but I hope this is changed in a future release.

Regardless, for me personally it is failing even with selector and expect on the same line and I've forked @Ogurecher 's sample repo and made a reproducable sample: https://github.com/favna/warning-example
Simply run npm run test to run testcafe here

_Originally posted by @Favna in https://github.com/DevExpress/testcafe/pull/5250#issuecomment-678322252_

server critical API bug

Most helpful comment

I set the critical status for this issue. We are trying to find a solution as soon as possible, stay tuned for updates.

All 7 comments

@Favna, Thank you for the example. I've reproduced the issue on my side.

Thanks for migrating my comment to an issue and trying my sample. Looking forward to see progress here.

Can this be solved already?

Makes looking through logs a nightmare I have to scroll thousands of lines of this useless warning to find what actually failed.

At least give an option to disable the warning.

I set the critical status for this issue. We are trying to find a solution as soon as possible, stay tuned for updates.

@xorxero: I just stumbled upon this issue. A workaround is described here

For the team:
This issue is caused by the same reason as #5389.

When the snapshot property promise is resolved, its callsite is saved to a callsite storage. We check this storage in the .expect assertion call. If the storage contains a callsite with the same filename and lineNumber as the .expect's callsite, we delete it and raise a warning.

If the property was not awaited, the .expect would execute before the property promise's .then method. Thus, some callsites would remain in the storage after they were asserted (we delete them only in .expect). It works fine if we use our assertion only once, but causes the warnings to raise if we call .expect from the same line of code again.

Was this page helpful?
0 / 5 - 0 ratings