How to have less flaky tests from the start of your development. Use repeat each to have confidence in your playwright tests.
In the tutorial video shared by Jared from Commit Quality, he discusses a certain feature offered by Playwright, known as the 'repeat each' option, which certifies the quality of testings carried out in any software development process.
Playwright is a Node.js testing utility that allows quality checks to be run for server-based applications. Its 'repeat each' feature essentially reiterates any test multiple times to enable a more confident and robust result. This process ensures the reliability of the test, thereby making it more stable and non-flaky.
The video demonstrates this feature with a primary test case where a basic test navigates to the Playwright webpage and expects the title to have the text 'Playwright'. This operation is carried using the 'dot only' annotation which ensures that only the test under consideration is run.
Iterating this test multiple times before the initiation of a pull request (a feature in version control systems to incorporate changes from a different branch into the main branch) provides deemed confidence that the created test is reliable and ready for launching.
The 'repeat each' option also eliminates manual reiterations since the option standardizes the number of repetitions. This can be added in the command line of the terminal by typing 'npx playwright test --repeat-each N', where 'N' represents the number of required repetitions.
When the command is executed, it ensures that the test runs 'N' times, certifying its stability. The video further explains that the number of tests run can be configured simultaneously with the configuration of the number of workers allotted, which opens the floor for parallelization testing as well.
The usage of this feature is not limited to only one test, but can be extended to multiple tests. An update in the number of tests run, subsequently updates the number of specified options. Therefore, if two tests are run three times each, it would mean running six tests in parallel.
A practical demonstration in the video where two tests are run three times verifies the utility of this option. The video concludes by emphasising the importance of the 'repeat each' option and encourages the usage of this for producing reliable tests.
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].