a beginner friendly, but in depth walk through of playwright assertions.
In this video, we got to learn about Playwright Test Assertions and how they can be used effectively for robust end-to-end testing. Jared, our guide, started by introducing us to the 'expect' library used for these test assertions alongside the Playwright Test package.
Playwright test assertions tend to be synchronous, but they could also be expanded with convenient async matches that would wait for an expected condition to be met until a timeout is reached; these are referred to as web-first assertions. Jared demonstrated this concept by running a simple code snippet in Visual Studio Code.
He explained how we could customize our error messages to make them more informative and relevant to the nature of our test. He then went ahead to demonstrate the workings of web-first assertions using a simple example and its response to changes in data and timeout settings.
In the discussion, Jared touched on another important topic: polling. Polling helps convert any synchronous test expectation into an asynchronous polling one, continuously looping over a function until the desired outcome is reached. This function was demonstrated by writing an example code with failure by design and explaining its execution.
Jared also pointed out the possibility of executing soft assertions which allow the test to continue upon failure. It only marks the test as failed at the end of its run if there was a failure executing the soft assertions.
The video also emphasized the importance of using the Playwright documentation as a reference to resolve any concerns or confusion. It wrapped up with Jared urging watchers to raise any questions or doubts they have in a comment and expressing his appreciation for their time.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].