'How to run selected feature files/scenarios in cypress cucumber and skip others
I tried several commands but nothing seems to work. Either it escapes all or runs none.
@TestFeature
Feature: Test Feature
Testing sample feature
Background: Logging in
@manual
Scenario: A
Given
Scenario Outline: B
I want to run Test Feature
and skip the scenarios marked manual
. I tried -
npx cypress run --env TAGS=@TestFeature and not @manual --browser chrome
But it doesn't work. Also tried similar combinations, but none work.
Solution 1:[1]
You are able to use @tags in Feature Files and get Cypress to run selected tests only. You need to be careful to escape inverted commas. The following worked for me (running tests tagged with @accessibility tag):
package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"test:accessibility": "./node_modules/.bin/cypress-tags run -e TAGS=\"@accessibility\"",
"test": "cypress run --spec \"**/*.feature\"",
"eject": "react-scripts eject"
},
Then at the command prompt:
cypress-tags run -e TAGS="@accessibility"
Solution 2:[2]
As far as I know it isn't currently not possible to run tests with a tag. You could create an issue for this in github ( https://github.com/cypress-io/cypress/issues ) to let them implement it.
As a work around we choose to create smoketests and featuretests. The smoketests are in a seperate directory which enables us to only run those test scenario's in stead of the whole test suite. You can do so by running the tests with this command:
npx cypress run --spec /cypress/smoketest/*
Solution 3:[3]
You can use the @focus tag. See https://www.npmjs.com/package/cypress-cucumber-preprocessor
@focus
Scenario: Opening a search engine page
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | palaѕн |
Solution 2 | Mr. J. |
Solution 3 | TenPotatoes |