Skip to content

Commit 05425f1

Browse files
committed
Add gherkin lint in the project
1 parent b9aa5a7 commit 05425f1

File tree

7 files changed

+242
-12
lines changed

7 files changed

+242
-12
lines changed

.gherkin-lintrc.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"no-files-without-scenarios": "on",
3+
"no-unnamed-features": "on",
4+
"no-unnamed-scenarios": "on",
5+
"no-dupe-scenario-names": ["on", "in-feature"],
6+
"no-dupe-feature-names": "on",
7+
"no-partially-commented-tag-lines": "on",
8+
"indentation": [
9+
"on",
10+
{
11+
"Feature": 0,
12+
"Background": 4,
13+
"Scenario": 4,
14+
"given": 8,
15+
"when": 8,
16+
"then": 8,
17+
"and": 12,
18+
"feature tag": 0,
19+
"scenario tag": 4,
20+
"Examples": 8,
21+
"example": 8
22+
}
23+
],
24+
"no-trailing-spaces": "on",
25+
"new-line-at-eof": ["on", "yes"],
26+
"no-multiple-empty-lines": "on",
27+
"no-empty-file": "on",
28+
"no-scenario-outlines-without-examples": "on",
29+
"use-and": "on",
30+
"no-duplicate-tags": "on",
31+
"no-superfluous-tags": "on",
32+
"no-homogenous-tags": "off",
33+
"one-space-between-tags": "on",
34+
"no-unused-variables": "on",
35+
"no-background-only-scenario": "on",
36+
"no-empty-background": "on",
37+
"scenario-size": [
38+
"on",
39+
{ "steps-length": { "Background": 10, "Scenario": 75 } }
40+
]
41+
}

.huskyrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"hooks": {
3-
"pre-commit": "npm run code:format && npm run build"
3+
"pre-commit": "npm run code:format && npm run code:gherkin && npm run build"
44
}
55
}

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ npm install
1919
Run e2e tests:
2020

2121
```bash
22-
yarn tests:e2e
22+
npm run tests:e2e
2323
```
2424

2525
## Spoken Languages
@@ -33,13 +33,13 @@ If you want to use another language in features files, you can see this [doc](ht
3333
Run this command to generate the allure report in the directory `./test-report/allure-report`:
3434

3535
```bash
36-
yarn report:generate
36+
npm run report:generate
3737
```
3838

3939
You can run this command to start a server on your machine and open the allure report on the browser:
4040

4141
```bash
42-
yarn report:open
42+
npm run report:open
4343
```
4444

4545
### Time line reporter
@@ -51,5 +51,13 @@ You can see [Timeline report](https://github.com/QualityOps/wdio-timeline-report
5151
Run to format the code:
5252

5353
```bash
54-
yarn code:format
54+
npm run code:format
55+
```
56+
57+
## Gherkin lint
58+
59+
We use [Gherkin lint](https://github.com/vsiakka/gherkin-lint) to keep the feature files organized.
60+
61+
```bash
62+
npm run code:gherkin
5563
```

package-lock.json

Lines changed: 181 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"scripts": {
1010
"build": "rm -rf ./dist && npx tsc && cp -R ./src/test/e2e/features ./dist/src/test/e2e",
1111
"code:format": "prettier --check \"src/**/*.ts*\" --write",
12+
"code:gherkin": "npx gherkin-lint -c .gherkin-lintrc.json src/test/e2e/features",
1213
"report:generate": "npx allure generate --clean ./test-report/allure-result/ -o ./test-report/allure-report",
1314
"report:open": "npx allure open test-report/allure-report",
1415
"tests:e2e": "wdio ./dist/wdio.conf.js"
@@ -35,6 +36,7 @@
3536
"@types/node": "^14.6.4",
3637
"husky": "^4.3.0",
3738
"prettier": "^2.1.1",
39+
"gherkin-lint": "^4.1.2",
3840
"ts-node": "^9.0.0",
3941
"typescript": "^4.0.2"
4042
}

src/test/e2e/features/Login.feature

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
Feature: Performing a login
22

3-
Background:
4-
Given I'm on the login page
5-
63
Scenario: Login with a default user
4+
Given I'm on the login page
75
When I log in with a default user
86
Then show a welcome message on the site
9-
And show user name 'Leandro Nelson Gael Castro' on the site
7+
And show user name 'Leandro Nelson Gael Castro' on the site

src/test/e2e/features/SendMessage.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ Feature: Sending message to customer service
22

33
Scenario: Show the customer service label
44
Given I'm on the login page
5-
And I log in with a default user
5+
And I log in with a default user
66
When I'm on the contact page
77
Then the system shows a customer service label
88

99
Scenario: Attaching a document to the message to the customer
1010
Given I'm on the login page
11-
And I log in with a default user
12-
And I'm on the contact page
11+
And I log in with a default user
12+
And I'm on the contact page
1313
When I send a message with a document
1414
Then the system shows a successful message

0 commit comments

Comments
 (0)