You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, in my project I have a bug, when I quickly cycle between two tabs, for a split second the tab content displays something that it shouldn't. I was thinking about writing a test for it, but it seems impossible to have a reliable test for it. Here's what I did:
The new ensure_condition() context manager would work similarly to expect(), but instead of waiting for the condition to be met, it will ensure it is like that for the whole with block. That means that the unwanted-section showing up anytime while this block is active will trigger an error. This could be also slightly extended (maybe parametrized?) to allow also catching elements that are expected to show for a brief moment, which is also hard to catch with regular except(). But in this case the ensure_condition() or equivalent would need to react on the condition being met at least once within the with block.
Playwright can not detect something that shows up for a split second as of today. If I were to implement something like this, I would do that in the web page via using MutationObserver. I would evaluate code that install mutation observer and calls console.log when it detected something that should not happen. I would log all the console messages and assert them after the test.
Currently, in my project I have a bug, when I quickly cycle between two tabs, for a split second the tab content displays something that it shouldn't. I was thinking about writing a test for it, but it seems impossible to have a reliable test for it. Here's what I did:
The problem is that this test will always pass since the first
expect()
will wait until the unwanted element is gone.What would be helpful in this case, is a simple context manager:
The new
ensure_condition()
context manager would work similarly toexpect()
, but instead of waiting for the condition to be met, it will ensure it is like that for the wholewith
block. That means that theunwanted-section
showing up anytime while this block is active will trigger an error. This could be also slightly extended (maybe parametrized?) to allow also catching elements that are expected to show for a brief moment, which is also hard to catch with regularexcept()
. But in this case theensure_condition()
or equivalent would need to react on the condition being met at least once within thewith
block.This seems to be a bit similar to microsoft/playwright-python#1638.
The text was updated successfully, but these errors were encountered: