-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix sync tests getting skipped in parallel mode. (#3791)
- Loading branch information
Showing
7 changed files
with
104 additions
and
15 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
11 changes: 11 additions & 0 deletions
11
test/apidemos/custom-commands-parallel/testUsingES6AsyncCustomCommands.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,11 @@ | ||
describe('Test Using Sync Custom Command returning NightwatchAPI', function() { | ||
before(browser => { | ||
browser.url('http://localhost'); | ||
}); | ||
|
||
it('sampleTest', browser => { | ||
browser | ||
.otherCommand() | ||
.end(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
command: function() { | ||
return this; | ||
module.exports = class OtherCommand { | ||
command() { | ||
return this.api.pause(10); | ||
} | ||
}; |
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,20 @@ | ||
{ | ||
"src_folders" : ["./test/apidemos/custom-commands-parallel"], | ||
"test_workers": true, | ||
"custom_commands_path": ["./test/extra/commands/other"], | ||
"persist_globals": true, | ||
"output_folder" : false, | ||
"output" : false, | ||
"silent": false, | ||
"selenium" : { | ||
"start_process" : false, | ||
"port": 10195 | ||
}, | ||
"test_settings": { | ||
"default" : { | ||
"desiredCapabilities" : { | ||
"browserName" : "firefox" | ||
} | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
test/src/apidemos/custom-commands/testCustomCommandSync.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,49 @@ | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
const MockServer = require('../../../lib/mockserver.js'); | ||
const Mocks = require('../../../lib/command-mocks.js'); | ||
const common = require('../../../common.js'); | ||
const {settings} = common; | ||
const NightwatchClient = common.require('index.js'); | ||
|
||
describe('sync custom commands', function() { | ||
beforeEach(function(done) { | ||
this.server = MockServer.init(); | ||
this.server.on('listening', () => { | ||
done(); | ||
}); | ||
}); | ||
|
||
afterEach(function(done) { | ||
this.server.close(function() { | ||
done(); | ||
}); | ||
}); | ||
|
||
it('test sync custom command returning NightwatchAPI as result', function() { | ||
const testsPath = path.join(__dirname, '../../../apidemos/custom-commands-parallel'); | ||
Mocks.createNewW3CSession({ | ||
testName: 'Test Sync Custom Commands returning NightwatchAPI' | ||
}); | ||
|
||
const globals = { | ||
waitForConditionPollInterval: 50, | ||
waitForConditionTimeout: 120, | ||
retryAssertionTimeout: 1000, | ||
|
||
reporter(results) { | ||
assert.strictEqual(Object.keys(results.modules).length, 1); | ||
if (results.lastError) { | ||
throw results.lastError; | ||
} | ||
} | ||
}; | ||
|
||
return NightwatchClient.runTests({ | ||
env: 'default', | ||
config: 'test/extra/parallelism-customCommandsSync.json' | ||
}, Object.assign({}, { | ||
globals | ||
})); | ||
}); | ||
}); |