Do Chromatic tests complement Playwright tests?

I am using Playwright to automate end-to-end tests, and have started to complement my Playwright tests with Chromatic tests. 

The Playwright tests are really useful, but each test needs to run through several steps to create a scenario I want to test. Creating a Playwright test for each input variation for each part of the UI would be expensive. I would like a test automation tool to check a wide range of inputs for each element of the UI that does not require automating a large number of steps.

I have been introduced to Chromatic by a developer. Chromatic is a test tool that is made by the team behind Storybook. If your team uses Storybook you can use Chromatic to test for visual regressions in UI components. Chromatic tests can be described as “unit tests for visual states”. 

Chromatic can be used to test each component in the UI. With Chromatic you can, for instance, create tests that check how a component handles the values that can be entered into an input field. Chromatic tests are like unit tests and do not require steps to set them up, also each test runs quickly so you can create Chromatic tests for all the inputs you would like without worrying that the test pack will take a long time to run. A Playwright test of each of these inputs would have the disadvantage of requiring automating several steps to set the test up before testing the inputs.

Chromatic tests can be written in javascript or typescript. An example test is below:

Chromatic tests can be written in more than one way:

Chromatic is a test automation tool that can complement Playwright, this is because I can write end-to-end tests in Playwright that test flows through the application and write “visual unit tests” in Chromatic that test a wide variety of inputs into individual UI components.

Published by Mike Harris

Mike has been working in testing for 20 years and is the lone tester for Geckoboard. He has been a Test Lead and has also worked as a part of waterfall, lean and agile teams. He has a B.Sc.(HONS) from Middlesex University and is an Associate of the University of Hertfordshire. He has set up and led a Testing Community of Practice and been part of a successful agile transition. He is Vice-Chair of the British Computer Society’s Specialist Interest Group in Software Testing. He also contributed to the e-books Testing Stories and How Can I test This? and has had articles published by the Ministry of Testing, LambdaTest and The QA Lead.

Leave a comment

Design a site like this with WordPress.com
Get started