Skip to content

Commit

Permalink
Add global Cucumber hooks using cucumber.conf.js (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 authored Aug 7, 2024
1 parent c2e4351 commit 0a51980
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run eslint
- run: npm test -- --env chrome --headless
- run: npm test -- --env chrome --headless --tags "not @duckduckgo"
13 changes: 13 additions & 0 deletions cucumber.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const {AfterStep} = require('@cucumber/cucumber');

AfterStep(async function(testCase) {
// take screenshot on test case failure.
//
// follow this Discord thread for integrating the screenshots into your Cucumber report:
// https://discord.com/channels/618399631038218240/1253341054921609306/1255939897047515250
//
if (testCase.result.status === 'FAILED' && this.browser) {
await this.browser.saveScreenshot(`screenshots/${testCase.pickle.name}.png`);
}
});

3 changes: 2 additions & 1 deletion nightwatch.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = {
options: {
feature_path: 'tests/features/*.feature',
additional_config: '',
parallel: 2
parallel: 2,
require: ['./cucumber.conf.js']
}

},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "test"
},
"scripts": {
"test": "nightwatch",
"test": "nightwatch --env chrome --tags 'not @duckduckgo'",
"eslint": "eslint src/specs --quiet"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion tests/features/githubSearch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: Github test
Scenario: open URL
Given I open the url "https://github.com/"
Then I expect the url to contain "github.com"
And I expect that the title is GitHub: Let’s build from here · GitHub"
And I expect that the title is "GitHub: Let’s build from here · GitHub"

@githubSearch
Scenario: search for nightwatch repository
Expand Down

0 comments on commit 0a51980

Please sign in to comment.