Logo
BlogToast.
HomeAll PostsCategoriesRandom
Sign in
Logo
BlogToast.

Discover stories, insights, and perspectives from writers around the world.

Explore

  • All posts
  • Categories
  • Random

Dashboard

  • Sign in
  • Sign up
  • Forgot password

Legal

  • Contact
  • Privacy policy
  • Terms of service

© 2026 BlogToast. All rights reserved.

Use cypress tags (grepTags): An Ultimate guide.
Education2 min read

Use cypress tags (grepTags): An Ultimate guide.

N

N@rutO

October 30, 2024

When we run test in cypress, it runs all the specs that is available. But what if we want to test only important specs. These important specs come into smoke testing. In this tutorial, we will learn about tags and run tests based on these tags.

First we separate specs by using tags. For example, important testing will have @smoke tag and unimportant tests will have @regression tag while it will also have its own categorized tag like, for login its auth, for transactions its @payment.

Lets dive into using the tags and then we run only the tests that is needed. Follow these steps:

  1. Install Greptags from cypress

    npm i @cypress/grep
  2. Use this package as a plugin in cypress config

    e2e: {
        setupNodeEvents(on, config) {
          require("@cypress/grep/src/plugin")(config);

    Here, plugin is imported from @cypress/grep/src/plugin and initialized in config.

  3. At the end of e2e, the config must be returned.

    return config;
        }, 
  4. in module.exports of cypress config, enable grepFilter

    module.exports = defineConfig({
    env: {
        grepFilterSpecs: true,
      },
  5. Add tags in test

    describe("File download", { tags: "@smoke" }, () => {
    describe("File upload", { tags: ["@smoke", "@upload"] }, () => {

    For single tag, use string and for multiple tags, use list of strings.

  6. Run cypress test with tags in the env.

    npx cypress run --env grepTags='@smoke'

    This will run all the tests with tag @smoke

  7. To run tests with multiple tags

    npx cypress run --env grepTags='@smoke+@payment'

Tags

cypress tags greptags grep
Advertisement

Discussion (0)

Related Blogs

Explore similar articles

What to do immediately after database update in laravel?
Education
3 min

What to do immediately after database update in laravel?

J

N@rutO

Aug 14

2 0
Setup environment variables in cypress: A comprehensive guide.
Education
2 min

Setup environment variables in cypress: A comprehensive guide.

J

N@rutO

Sep 18

0 0