cypress-tags is a Cypress plugin that enables the organization and filtering of test runs using custom tags. It allows developers to assign tags (e.g., 'smoke', 'wip', 'regression') to `describe` and `it` blocks within their Cypress tests. The plugin then uses environment variables (`CYPRESS_INCLUDE_TAGS`, `CYPRESS_EXCLUDE_TAGS`) to selectively include or exclude tests during a run, facilitating granular control over test execution strategies. It supports boolean logic (AND/OR) for combining tags and even full boolean expressions, moving beyond simple comma-separated lists for more complex filtering. The current stable version is 1.2.2, with releases typically tied to feature enhancements or compatibility updates. A key differentiator is its preprocessor-based approach that integrates directly into Cypress's build pipeline, requiring TypeScript for parsing. This ensures type safety and a seamless development experience for TypeScript users, providing a more robust tagging solution compared to purely runtime-based alternatives.
npm install cypress-tagsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure `cypress-tags` in `cypress.config.ts`, update Cypress type definitions, define and use enum-based tags in test files, and execute filtered test runs using environment variables including boolean expressions.
Ensure `typescript` is installed as a dev dependency: `npm install --save-dev typescript`.
Add `/// <reference types='cypress-tags' />` to `cypress/support/index.d.ts`.
Set the respective `CYPRESS_INCLUDE_USE_BOOLEAN_AND` or `CYPRESS_EXCLUDE_USE_BOOLEAN_AND` environment variable to `true` for AND logic.
Set `CYPRESS_USE_INCLUDE_EXCLUDE_EXPRESSIONS=true` alongside your expression-based environment variables.
Ensure `/// <reference types='cypress-tags' />` is present in your `cypress/support/index.d.ts` file.
Install TypeScript: `npm install --save-dev typescript`.
Ensure `npm install cypress-tags --save-dev` has been run and `import { tagify } from 'cypress-tags';` is at the top of your `cypress.config.ts`.