-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes/consider test suite settings in cucumber runner (#3622)
- Loading branch information
Showing
7 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
5 changes: 5 additions & 0 deletions
5
...tegration-tests/sample_cucumber_tests/with-modified-settings/plugin/nightwatch/globals.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
before(settings) { | ||
settings.desiredCapabilities.browserName = 'chrome'; | ||
} | ||
}; |
31 changes: 31 additions & 0 deletions
31
test/cucumber-integration-tests/sample_cucumber_tests/with-modified-settings/testSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const assert = require('assert'); | ||
const {Given, Then, After} = require('@cucumber/cucumber'); | ||
|
||
Given('I navigate to localhost', function() { | ||
browser.globals.test_calls = 0; | ||
browser.globals.test_calls++; | ||
|
||
return browser.navigateTo('http://localhost'); | ||
}); | ||
|
||
Then('I check if webdriver is present', function() { | ||
browser.globals.test_calls++; | ||
|
||
return browser.assert.elementPresent('#webdriver'); | ||
}); | ||
|
||
Then('I check if webdriver is present and contains text', async function() { | ||
browser.globals.test_calls++; | ||
|
||
await browser.expect.element('#webdriver').text.to.contain('xx') | ||
}); | ||
|
||
Then('I check if badElement is present', function() { | ||
browser.globals.test_calls++; | ||
|
||
return browser.assert.elementPresent('#badElement'); | ||
}); | ||
|
||
After(function() { | ||
assert.strictEqual(browser.globals.test_calls, 2); | ||
}); |
57 changes: 57 additions & 0 deletions
57
test/cucumber-integration-tests/testCucumberTestsWithModifiedSettings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
const Globals = require('../lib/globals/commands.js'); | ||
const common = require('../common.js'); | ||
const MockServer = require('../lib/mockserver.js'); | ||
const {runTests} = common.require('index.js'); | ||
|
||
describe('Cucumber integration - with modified settings in plugin', function() { | ||
beforeEach(function(done) { | ||
this.server = MockServer.init(null, {port: 10195}); | ||
this.server.on('listening', () => done()); | ||
}); | ||
|
||
afterEach(function(done) { | ||
Globals.afterEach.call(this, done); | ||
}); | ||
|
||
it('testCucumberSampleTests with browsername modified (chrome) in plugin global hook', function() { | ||
const source = [path.join(__dirname, './sample_cucumber_tests/with-modified-settings/testSample.js')]; | ||
|
||
|
||
const pluginPath = [path.join(__dirname, './sample_cucumber_tests/with-modified-settings/plugin')]; | ||
|
||
MockServer.addMock({ | ||
url: '/wd/hub/session', | ||
method: 'POST', | ||
statusCode: 201, | ||
postdata: { | ||
capabilities: { | ||
firstMatch: [{}], | ||
alwaysMatch: {browserName: 'chrome', 'goog:chromeOptions': {}} | ||
} | ||
}, | ||
response: { | ||
status: 0, | ||
sessionId: '1352110219202', | ||
value: {browserName: 'chrome', browserVersion: 'TEST_chrome'}, | ||
state: null | ||
} | ||
}, true); | ||
|
||
|
||
// modify browserName to chrome in plugin global hook | ||
return runTests({ | ||
source, | ||
tags: ['@pass'], | ||
verbose: false, | ||
config: path.join(__dirname, '../extra/cucumber-config.js') | ||
}, { | ||
plugins: pluginPath | ||
}) | ||
.then(failures => { | ||
assert.strictEqual(failures, false); | ||
}); | ||
}); | ||
|
||
}); |