Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityvi committed Jun 8, 2023
1 parent 817c2ed commit 6236818
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions test/src/runner/testRunBrowserstackTransport.js
Expand Up @@ -7,7 +7,7 @@ const {settings} = common;
const {runTests} = common.require('index.js');

describe('testRunBrowserstackTransport', function() {
let nockDone = false;
let nockCalled = 0;

before(function(done) {
try {
Expand All @@ -17,6 +17,7 @@ describe('testRunBrowserstackTransport', function() {

nock('https://hub-cloud.browserstack.com')
.post('/wd/hub/session')
.times(2)
.reply(201, (uri, requestBody) => {
assert.ok(requestBody.capabilities.alwaysMatch['bstack:options'].sessionName, 'session request should contain session Name');

Expand All @@ -31,23 +32,27 @@ describe('testRunBrowserstackTransport', function() {

nock('https://api.browserstack.com')
.get('/automate/builds.json')
.times(2)
.reply(200, []);

nock('https://hub-cloud.browserstack.com')
.post('/wd/hub/session/1352110219202/url')
.times(2)
.reply(200, {
value: null
});

nock('https://hub-cloud.browserstack.com')
.post('/wd/hub/session/1352110219202/elements')
.times(2)
.times(5)
.reply(200, {
value: []
});

nock('https://hub-cloud.browserstack.com')
.delete('/wd/hub/session/1352110219202')
.times(2)
.reply(200, {
value: []
});
Expand All @@ -57,8 +62,9 @@ describe('testRunBrowserstackTransport', function() {
status: 'failed',
reason: /^NightwatchAssertError: Testing if element <#weblogin> is present in 10ms/
})
.times(2)
.reply(200, function() {
nockDone = true;
nockCalled++;

return {};
});
Expand All @@ -74,8 +80,11 @@ describe('testRunBrowserstackTransport', function() {
it('run with error', function() {
const testsPath = path.join(__dirname, '../../sampletests/withfailures/');

return runTests(testsPath, settings({
output: false,
return runTests({
suiteRetries: 1,
source: testsPath
}, settings({
output: true,
silent: false,
webdriver: {
host: 'hub-cloud.browserstack.com',
Expand All @@ -94,7 +103,7 @@ describe('testRunBrowserstackTransport', function() {
waitForConditionTimeout: 11,
retryAssertionTimeout: 10,
reporter(results) {
assert.ok(nockDone, 'Failed mock requests');
assert.strictEqual(nockCalled, 2);
assert.strictEqual(Object.keys(results.modules).length, 1);
}
}
Expand Down

0 comments on commit 6236818

Please sign in to comment.