Skip to content

Commit

Permalink
Fix closing automate session twice; Bump version (v1.7.2) (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyBelym authored Jan 31, 2019
1 parent 58f55a9 commit 2d2b55a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testcafe-browser-provider-browserstack",
"version": "1.7.1",
"version": "1.7.2",
"description": "browserstack TestCafe browser provider plugin.",
"repository": "https://github.com/DevExpress/testcafe-browser-provider-browserstack",
"engines": {
Expand Down
11 changes: 9 additions & 2 deletions src/backends/automate.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,16 @@ export default class AutomateBackend extends BaseBackend {
}

async closeBrowser (id) {
clearInterval(this.sessions[id].interval);
const session = this.sessions[id];

await requestApi(BROWSERSTACK_API_PATHS.deleteSession(this.sessions[id].sessionId));
if (!session)
return;

delete this.sessions[id];

clearInterval(session.interval);

await requestApi(BROWSERSTACK_API_PATHS.deleteSession(session.sessionId));
}

async takeScreenshot (id, screenshotPath) {
Expand Down
44 changes: 31 additions & 13 deletions test/mocha/browser-names-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,40 @@ describe('Browser names', function () {
});

it('Should return list of common browsers and devices', function () {
const IS_AUTOMATE = process.env['BROWSERSTACK_USE_AUTOMATE'] && process.env['BROWSERSTACK_USE_AUTOMATE'] !== '0';

const REST_BROWSER_NAMES = [
'[email protected]:OS X Mavericks',
'[email protected]:OS X Yosemite',
'[email protected]:OS X El Capitan',
'[email protected]:Windows 7',
'[email protected]:Windows 8',
'[email protected]:Windows 8.1',
'[email protected]:Windows 10',
'iPhone [email protected]',
'iPhone [email protected]',
'iPhone [email protected]',
'Google Nexus [email protected]'
];

const AUTOMATE_BROWSER_NAMES = [
'[email protected]:OS X Mavericks',
'[email protected]:OS X Yosemite',
'[email protected]:OS X El Capitan',
'[email protected]:Windows 7',
'[email protected]:Windows 8',
'[email protected]:Windows 8.1',
'[email protected]:Windows 10',
'iPhone 7@10',
'iPhone SE@11',
'iPhone XR@12',
'Google Nexus [email protected]'
];

return browserStackProvider
.getBrowserList()
.then(function (list) {
expect(list).to.include.members([
'[email protected]:OS X Mavericks',
'[email protected]:OS X Yosemite',
'[email protected]:OS X El Capitan',
'[email protected]:Windows 7',
'[email protected]:Windows 8',
'[email protected]:Windows 8.1',
'[email protected]:Windows 10',
'iPhone [email protected]',
'iPhone [email protected]',
'iPhone [email protected]',
'Google Nexus [email protected]'
]);
expect(list).to.include.members(IS_AUTOMATE ? AUTOMATE_BROWSER_NAMES : REST_BROWSER_NAMES);
});
});

Expand Down

0 comments on commit 2d2b55a

Please sign in to comment.