2

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.

Fody
  • 23,754
  • 3
  • 20
  • 37
Aishwarya
  • 45
  • 6

2 Answers2

2

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
Fody
  • 23,754
  • 3
  • 20
  • 37
  • This is not working. – Aishwarya Jun 07 '22 at 08:42
  • It's pretty simple and straightforward, not much to get wrong. – Fody Jun 07 '22 at 09:26
  • Actually my question was whether is it possible to display only the specs you want to run on the test runner window. Actually the method that you have mentioned in the answer will work by using a command. But I only want to display (login.spec.js, admin.spec.js and customer.spec.js) files on the test runner window. – Aishwarya Jun 08 '22 at 04:20
1

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
Aravinth
  • 254
  • 3
  • 14