How to Exclude few specs from running from Cypress run command but should be able to run via import command from other spec

552 views Asked by At

How to exclude certain specs to be run in the folder when npx cypress run is executed for example please see the image

I don't want to execute my spec which is in Marketing/Sales/sc1111.spec.ts but at the same time I want it to execute via the import statement mentioned in Finance/Verify/sc1111-main.spec.ts

is there anything that I can do in the folder level itself to stop it from running asking this as I have 100's of folders that are going to be like this and I don't want to mess up the configuration file with excluding list so Please help me regarding this with your suggestions enter image description here

1

There are 1 answers

0
TesterDick On

There is a configuration option to exclude files

Configuration - e2e

excludeSpecPattern
A String or Array of glob patterns used to ignore test files that would otherwise be shown in your list of tests.


Minimal reproducible example

If I set up a simple project with three spec files

enter image description here

then add test-b.cy.js to the exclude pattern

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

module.exports = defineConfig({
  e2e: {
    excludeSpecPattern: 'cypress/e2e/test-b.cy.js'
  },
})

when I execute yarn cypress run, test-b.cy.js isn't run.

enter image description here