Test Tags | Bondar Academy
Course: Cypress UI Testing with JavaScript
Module: Advanced Features
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore the concept of test tags in Cypress, particularly useful for managing large test suites with multiple spec files. Test tags allow you to run specific tests across various spec files by marking them with designated tags. Configuring Test Tags To use test tags, we need to install a plugin called Cypress-grep . Here are the steps to configure it: Install Cypress-grep: Open the terminal in your Conduit Cypress project and run the installation command. Add Configuration: Insert the necessary lines into e2e.js . Setup Node Events: Add the required lines into setupNodeEvents . Basic Usage Once configured, you can use the grep command to target tests by their names or tags. For example: npx cypress run --env grep=smoke This command executes only the tests marked with the smoke tag. You can also assign multiple tags to a test by using an array. Advanced Filtering To exclude tests from the run, use the flag grep-filtered-spec=true . For complete isolation of tests, use grep-on-mid-filtered=true . Combining Tags You can combine tags in various ways: Run tests with either smoke or critical tags. Run tests with smoke but not slow tags. Burning Tests A useful feature is the burning test , which allows you to validate test stability by executing a test multiple times (e.g., burn=5 ). In summary, using the Cypress-grep plugin provides a reliable way to filter and execute only the necessary tests, enhancing test management efficiency.