Skip to content

Commit f43ca57

Browse files
committed
Document isFeature() and doesFeatureMatch(..)
1 parent 77e6868 commit f43ca57

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

docs/mixing-types.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Mixing Cucumber and non-Cucumber specs
2+
3+
Mixing Cucumber and non-Cucumber specs are supported. Cypress can be configured with `specPattern` to resolve multiple spec types as shown below.
4+
5+
```js
6+
export default defineConfig({
7+
e2e: {
8+
specPattern: "**/*.{spec.js,feature}"
9+
},
10+
});
11+
```
12+
13+
Cucumber hooks, IE. `Before` and `After` as imported from `@badeball/cypress-cucumber-preprocessor`, are *only* run in Cucumber-type specs.
14+
15+
You can determine spec-type in Cypress' own hooks using `isFeature()`, as shown below.
16+
17+
```js
18+
import { isFeature } from "@badeball/cypress-cucumber-preprocessor";
19+
20+
beforeEach(() => {
21+
if (isFeature()) {
22+
// This is only run for Cucumber-type specs.
23+
}
24+
})
25+
```
26+
27+
You can also created conditions based on tags using `doesFeatureMatch(..)`, as shown below.
28+
29+
```js
30+
import { isFeature, doesFeatureMatch } from "@badeball/cypress-cucumber-preprocessor";
31+
32+
beforeEach(() => {
33+
if (isFeature() && doesFeatureMatch("@foobar")) {
34+
// This is only run for Cucumber-type specs tagged with @foobar.
35+
}
36+
})
37+
```

docs/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
* [Configuration](configuration.md)
1515
* [Test configuration](test-configuration.md)
1616
* [Diagnostics / dry run](diagnostics.md)
17+
* [Mixing Cucumber and non-Cucumber specs](mixing-types.md)
1718
* [Frequently asked questions](faq.md)

0 commit comments

Comments
 (0)