ggonmar
ggonmar

Reputation: 839

How to execute only one test of a feature file?

I have a file with N>10 tests defined in BDD in a feature file.

For debugging purposes, I need to execute only one of the tests many times, but I am not finding any other way than commenting out the other tests.
I am trying now to use the @focus tag in front of the test, in a way that cypress IDE actually marks the rest of the tests as sync skip; aborting execution, but the test that I need to run actually says No commands were issued in this test..

This is the example .feature file I'm playing with:

@e2eTests
@cases
Feature: Test feature

 Scenario: Test 1
   Given foo
   When bar
   Then foobar

@focus
 Scenario: Test 2
   Given bar
   When foo
   Then barfoo!

And when running npm run cypress and selecting this feature, I get: cypressIDE

What am I doing wrong?

Thanks

Upvotes: 2

Views: 3063

Answers (1)

m_kos
m_kos

Reputation: 1809

I would recommend using cypress-grep if you are looking for a flaky test, that needs repeating n times.

After installation and configuration (see here: Burning Tests with cypress-grep) in terminal indicate which test needs to be repeated and how many times (cypress 7.6) ->

npx cypress run --spec cypress/folder/with/test/testFile.spec.ts, --env grep="name/description of specific test", burn= >>numberOfIterations<<

Example:

npx cypress run --spec cypress/integration/testExample.spec.ts, --env grep="A popup should appear after login",burn=250

Upvotes: 1

Related Questions