How to run all Specs /or selected Spec in Cypress v11.2.0
Tags: cypress, javascript, testing, beginners
Published: 2022-11-23 13:14:09

_**This blog was originally published in https://qaautomationlabs.com/how-to-run-all-specs-in-cypress-latest-version/**_

**Problem Statement**
The ability to ‘Run all specs’ or ‘Run filtered specs’ will be removed in Cypress 10.0. For many of the users, the existing implementation “was broken” for them because of how cypress originally architectured supporting this feature. Cypress received feedback regarding the removal of this feature.

In this blog for demo purposes, I am using Cypress version 11.2.0

**How to solve the problem**
In Cypress version 11.2.0 Cypress team has introduced a feature flag experimentalRunAllSpecs that will restore the prior behavior seen in versions < 10

**Steps to Implements ‘Run all specs’**
**Installing Cypress**
Installed Cypress version 11.2.0 using npm install cypress --save-dev

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gap5b6o9x4or1v8fgzmp.png)



**Keep feature flag disable**
After installing 11.2.0 next step is to enable experimentalRunAllSpecs flag.

Let's see when the feature flag experimentalRunAllSpecs is disabled. In the below screenshot, we can see the button to Run all specs is not displaying


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g5614b9otg9w3uqv7htn.png)


**Enable the feature flag**
When we enable the feature flag experimentalRunAllSpecs:true we can see in the below screenshot button to Run all specs is displaying

After enabling the feature flag either we can run all .specs in a single run or can run a set of .specs

1.We can run all test cases in a single run

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qe2dexyg41toh1kjsq3r.png)



2. We can run a SET of test cases e.g I want to run the First Set of Spec or Second Set of Spec or Third Set of Spec See in the above screenshot


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3ia1tq912zf0zdh9ukn.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1m0vko2oj45fvuiu9x4z.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2gl2bbmts7k0xuzn0ta6.png)






How to enable Feature Flag
In cypress.config.js set the below command

```
const { defineConfig } = require("cypress");

module.exports = defineConfig({
  e2e: {
    experimentalRunAllSpecs: true,
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
});

```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s97dlti61wpojpcwa5jf.png)


**Steps to run the filtered .specs**
If we want to run filtered spec we can simply search and execute the test

**Two ways of filtering the .specs file**

We can run the particular .spec file from the set of specs can be seen in below screenshot


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7klybv0mg01mj5n41t6a.png)


We can also search the .spec file from the Cypress runner and run the .spec file


**Conclusion**
The ability to ‘Run all specs’ or ‘Run filtered specs’ that was removed in the previous cypress version was re-introduced in Cypress version 11.2.0.

Using the experimentalRunAllSpecs feature flag we can restore the prior behavior and execute all/selected .specs files.