diff --git a/package.json b/package.json index 6c76fbf..9acb885 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/backends/automate.js b/src/backends/automate.js index c5c3a07..d8ddd49 100644 --- a/src/backends/automate.js +++ b/src/backends/automate.js @@ -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) { diff --git a/test/mocha/browser-names-test.js b/test/mocha/browser-names-test.js index 63bd22a..4303b0d 100644 --- a/test/mocha/browser-names-test.js +++ b/test/mocha/browser-names-test.js @@ -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 = [ + 'chrome@51.0:OS X Mavericks', + 'firefox@45.0:OS X Yosemite', + 'safari@9.1:OS X El Capitan', + 'ie@9.0:Windows 7', + 'ie@10.0:Windows 8', + 'ie@11.0:Windows 8.1', + 'edge@15.0:Windows 10', + 'iPhone 7@10.3', + 'iPhone SE@11.2', + 'iPhone XR@12.1', + 'Google Nexus 6@6.0' + ]; + + const AUTOMATE_BROWSER_NAMES = [ + 'chrome@51.0:OS X Mavericks', + 'firefox@45.0:OS X Yosemite', + 'safari@9.1:OS X El Capitan', + 'ie@9.0:Windows 7', + 'ie@10.0:Windows 8', + 'ie@11.0:Windows 8.1', + 'edge@15.0:Windows 10', + 'iPhone 7@10', + 'iPhone SE@11', + 'iPhone XR@12', + 'Google Nexus 6@6.0' + ]; + return browserStackProvider .getBrowserList() .then(function (list) { - expect(list).to.include.members([ - 'chrome@51.0:OS X Mavericks', - 'firefox@45.0:OS X Yosemite', - 'safari@9.1:OS X El Capitan', - 'ie@9.0:Windows 7', - 'ie@10.0:Windows 8', - 'ie@11.0:Windows 8.1', - 'edge@15.0:Windows 10', - 'iPhone 7@10.3', - 'iPhone SE@11.2', - 'iPhone XR@12.1', - 'Google Nexus 6@6.0' - ]); + expect(list).to.include.members(IS_AUTOMATE ? AUTOMATE_BROWSER_NAMES : REST_BROWSER_NAMES); }); });