Closed samijaber closed 7 months ago
Do you believe setting test.fail(true)
should ignore ANY failure? I feel like tests could get into a broken (/useless) state if that were the case, whereas limiting it to just assertions can be more targeted/intentional.
Just commenting to provide an opinion, and follow along with any discussion.
This sounds unexpected, I can repro. We'll look into it.
Turns out this is working as expected as per https://github.com/microsoft/playwright/issues/9373#issuecomment-938161218. You should make your test fail before the test timeout has reached.
waitForSelector has a timeout of 0 by default, so you should reduce it if you expect a failure. If expect() fails before the test-timeout has reached, it gets marked as passing.
@mxschmitt I would like to bring this issue back up, because I still regularly struggle with it in my day-to-day.
Full context:
Not all servers pass all tests: I am in the process of fixing bugs/adding feature coverage. I want to track which tests are falling for which parameters, to make sure I enable the tests when the bugs are fixed. This is why I rely on test.fail(condition)
instead of test.skip(condition)
.
However, according to this github issue, someone in my situation is unable to use the entirety of waitFor*
helpers in Playwright, because then I cannot expect test failures.
This makes using playwright tricky, because I have to either:
test.skip(isSDKFoo)
and hope that I remember to enable the tests when I fix the bug for isSDKFoo
What would your advice be for someone in my situation?
Source code
Test file (self-contained)
Steps
.waitFor*
commands are commented outExpected
I would expect timeout errors caused by
.waitFor*
functions to be ignored whentest.fail(true)
.Actual
test.fail(true)
only "allows"expect()
failures to pass.Let me know if my understanding of this feature is wrong!