Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global Cucumber hooks using cucumber.conf.js #2

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading