Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.22 KB

mixing-types.md

File metadata and controls

41 lines (30 loc) · 1.22 KB

← Back to documentation

Mixing Cucumber and non-Cucumber specs

Mixing Cucumber and non-Cucumber specs are supported. Cypress can be configured with specPattern to resolve multiple spec types as shown below.

export default defineConfig({
  e2e: {
    specPattern: "**/*.{spec.js,feature}"
  },
});

Cucumber hooks, IE. Before and After as imported from @badeball/cypress-cucumber-preprocessor, are only run in Cucumber-type specs.

You can determine spec-type in Cypress' own hooks using isFeature(), as shown below.

import { isFeature } from "@badeball/cypress-cucumber-preprocessor";

beforeEach(() => {
  if (isFeature()) {
    // This is only run for Cucumber-type specs.
  }
})

You can also created conditions based on tags using doesFeatureMatch(..), as shown below.

import { isFeature, doesFeatureMatch } from "@badeball/cypress-cucumber-preprocessor";

beforeEach(() => {
  if (isFeature() && doesFeatureMatch("@foobar")) {
    // This is only run for Cucumber-type specs tagged with @foobar.
  }
})

⚠️ You can however not invoke any other member from @badeball/cypress-cucumber-preprocessor (such as Before(..) or Given(..)) within non-Cucumber specs.