Home > Blockchain >  Is it possible to run only specific tests on Cypress through support/index.js?
Is it possible to run only specific tests on Cypress through support/index.js?

Time:06-08

I am trying to run only specific test. Say I have 50 test files inside integration folder and want only 10 of them to run. I am trying to configure this from support/index.js file like:

import './commands'
import '../integration/login.spec.js'
import '../integration/admin.spec.js'
import '../integration/customer.spec.js'

I want to only display the selected files (login.spec.js, admin.spec.js and customer.spec.js) on the test runner of Cypress. I don't want other test files to display. But the above code is not working.

CodePudding user response:

I would not bother using the support/index.js, just make a dummy spec and run that

// my-top-10-tests.spec.js

import './login.spec.js' 
import './admin.spec.js' 
import './customer.spec.js'
// and so on

CodePudding user response:

As @Fody mentioned in the another answer, adding another dummy spec file approach does work.

Hence adding a detailed explanation on that approach in cypress 10.0.3, Windows OS

Lets's say below is your script folder structure

cypress
  e2e
    small-Run
      theDummytest.cy.js
    Module-A
      test-Module-A.cy.js
    Module-B
      SubModule-BB
        test-SubModule-BB.cy.js

And this is how, you implement the dummy test file approach

import '../Module-A/test-Module-A.cy.js'
import '../Module-B/SubModule-BB/test-SubModule-BB.cy.js'

And in you CLI/CI?CMD run, you would be using the below line to invoke that selective script tests

npx cypress run --spec cypress\e2e\small-Run\*.cy.js
  • Related