forked from Klaveness-Digital/cypress-cucumber-preprocessor
-
-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathquick-start.md
52 lines (39 loc) · 1.47 KB
/
quick-start.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Installation
```
$ npm install @badeball/cypress-cucumber-preprocessor
```
# Configuration
[Configure](https://docs.cypress.io/guides/references/configuration) `specPattern` with `"**/*.feature"`, using EG. `cypress.config.ts`.
```js
import { defineConfig } from "cypress";
export default defineConfig({
e2e: {
specPattern: "**/*.feature"
}
});
```
Then configure your preferred bundler to process features files. See [examples/](../examples) for how-to using Browserify, Esbuild or Webpack. Esbuild is the recommended bundler if you have no particular requirements (it's by far the fastest).
Read more about configuration options at [docs/configuration.md](configuration.md).
# Write a test
Write Gherkin documents and add a file for type definitions with a corresponding name (read more about how step definitions are resolved in [docs/step-definitions.md](step-definitions.md)). Reading [docs/cucumber-basics.md](cucumber-basics.md) is highly recommended.
```cucumber
# cypress/e2e/duckduckgo.feature
Feature: duckduckgo.com
Scenario: visting the frontpage
When I visit duckduckgo.com
Then I should see a search bar
```
```ts
// cypress/e2e/duckduckgo.ts
import { When, Then } from "@badeball/cypress-cucumber-preprocessor";
When("I visit duckduckgo.com", () => {
cy.visit("https://www.duckduckgo.com");
});
Then("I should see a search bar", () => {
cy.get("input").should(
"have.attr",
"placeholder",
"Search the web without being tracked"
);
});
```