Skip to content

Commit 2d2b55a

Browse files
authored
Fix closing automate session twice; Bump version (v1.7.2) (#69)
1 parent 58f55a9 commit 2d2b55a

3 files changed

Lines changed: 41 additions & 16 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "testcafe-browser-provider-browserstack",
3-
"version": "1.7.1",
3+
"version": "1.7.2",
44
"description": "browserstack TestCafe browser provider plugin.",
55
"repository": "https://github.com/DevExpress/testcafe-browser-provider-browserstack",
66
"engines": {

src/backends/automate.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,16 @@ export default class AutomateBackend extends BaseBackend {
161161
}
162162

163163
async closeBrowser (id) {
164-
clearInterval(this.sessions[id].interval);
164+
const session = this.sessions[id];
165165

166-
await requestApi(BROWSERSTACK_API_PATHS.deleteSession(this.sessions[id].sessionId));
166+
if (!session)
167+
return;
168+
169+
delete this.sessions[id];
170+
171+
clearInterval(session.interval);
172+
173+
await requestApi(BROWSERSTACK_API_PATHS.deleteSession(session.sessionId));
167174
}
168175

169176
async takeScreenshot (id, screenshotPath) {

test/mocha/browser-names-test.js

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,40 @@ describe('Browser names', function () {
1717
});
1818

1919
it('Should return list of common browsers and devices', function () {
20+
const IS_AUTOMATE = process.env['BROWSERSTACK_USE_AUTOMATE'] && process.env['BROWSERSTACK_USE_AUTOMATE'] !== '0';
21+
22+
const REST_BROWSER_NAMES = [
23+
'chrome@51.0:OS X Mavericks',
24+
'firefox@45.0:OS X Yosemite',
25+
'safari@9.1:OS X El Capitan',
26+
'ie@9.0:Windows 7',
27+
'ie@10.0:Windows 8',
28+
'ie@11.0:Windows 8.1',
29+
'edge@15.0:Windows 10',
30+
'iPhone 7@10.3',
31+
'iPhone SE@11.2',
32+
'iPhone XR@12.1',
33+
'Google Nexus 6@6.0'
34+
];
35+
36+
const AUTOMATE_BROWSER_NAMES = [
37+
'chrome@51.0:OS X Mavericks',
38+
'firefox@45.0:OS X Yosemite',
39+
'safari@9.1:OS X El Capitan',
40+
'ie@9.0:Windows 7',
41+
'ie@10.0:Windows 8',
42+
'ie@11.0:Windows 8.1',
43+
'edge@15.0:Windows 10',
44+
'iPhone 7@10',
45+
'iPhone SE@11',
46+
'iPhone XR@12',
47+
'Google Nexus 6@6.0'
48+
];
49+
2050
return browserStackProvider
2151
.getBrowserList()
2252
.then(function (list) {
23-
expect(list).to.include.members([
24-
'chrome@51.0:OS X Mavericks',
25-
'firefox@45.0:OS X Yosemite',
26-
'safari@9.1:OS X El Capitan',
27-
'ie@9.0:Windows 7',
28-
'ie@10.0:Windows 8',
29-
'ie@11.0:Windows 8.1',
30-
'edge@15.0:Windows 10',
31-
'iPhone 7@10.3',
32-
'iPhone SE@11.2',
33-
'iPhone XR@12.1',
34-
'Google Nexus 6@6.0'
35-
]);
53+
expect(list).to.include.members(IS_AUTOMATE ? AUTOMATE_BROWSER_NAMES : REST_BROWSER_NAMES);
3654
});
3755
});
3856

0 commit comments

Comments
 (0)