forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowsers.test.js
More file actions
130 lines (116 loc) · 3.28 KB
/
browsers.test.js
File metadata and controls
130 lines (116 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const webdriver = require('selenium-webdriver');
const hash = require('child_process')
.execSync('git rev-parse --short HEAD')
.toString();
const delay = ms =>
new Promise(resolve => {
setTimeout(() => {
resolve();
}, ms);
});
function getCapabilities(browserInfo) {
return {
...browserInfo,
'browserstack.user': process.env.BROWSER_STACK_USER,
'browserstack.key': process.env.BROWSER_STACK_KEY,
'browserstack.local': 'true',
'browserstack.debug': 'true',
'browserstack.console': 'errors',
'browserstack.networkLogs': true,
build: hash,
};
}
function getDriver(capabilities) {
return new webdriver.Builder()
.usingServer('http://hub-cloud.browserstack.com/wd/hub')
.withCapabilities(capabilities)
.build();
}
function testPageWitCapabilities(capabilities) {
const driver = getDriver(getCapabilities(capabilities));
// Test if a sandbox can be loaded on IE11
return driver
.get(
'http://localhost:3000/#github/codesandbox/integration-sandboxes/tree/master/new'
)
.then(async () => {
const element = webdriver.By.css('h1');
await driver.wait(webdriver.until.elementLocated(element), 60000);
driver.quit();
});
}
const PARALLEL_INDEX = Number.parseInt(process.env.CIRCLE_NODE_INDEX, 10) || 0;
const usedDescribe = process.env.BROWSER_STACK_KEY ? describe : describe.skip;
usedDescribe('browser-tests', () => {
if (PARALLEL_INDEX === 0) {
test.skip('ie11', async () => {
// Input capabilities
const capabilities = {
browserName: 'IE',
browser_version: '11.0',
os: 'Windows',
os_version: '10',
resolution: '1024x768',
};
await testPageWitCapabilities(capabilities);
}, 130000);
test.skip('ios', async () => {
// Input capabilities
const capabilities = {
browserName: 'iPhone',
device: 'iPhone X',
real_mobile: 'true',
os_version: '11.0',
};
await testPageWitCapabilities(capabilities);
}, 130000);
test('firefox', async () => {
// Input capabilities
const capabilities = {
browserName: 'Firefox',
browser_version: '58.0',
os: 'Windows',
os_version: '10',
resolution: '1024x768',
};
try {
await testPageWitCapabilities(capabilities);
} catch (e) {
await delay(10000);
// Retry
await testPageWitCapabilities(capabilities);
}
}, 130000);
test('safari', async () => {
// Input capabilities
const capabilities = {
browserName: 'Safari',
browser_version: '11.0',
os: 'OS X',
os_version: 'High Sierra',
resolution: '1024x768',
};
try {
await testPageWitCapabilities(capabilities);
} catch (e) {
await delay(10000);
// Retry
await testPageWitCapabilities(capabilities);
}
}, 130000);
test.skip('android', async () => {
// Input capabilities
const capabilities = {
browserName: 'android',
device: 'Samsung Galaxy S8',
real_mobile: 'true',
os_version: '7.0',
};
await testPageWitCapabilities(capabilities);
}, 130000);
} else {
test('it just works', () => {
expect(1).toBe(1);
});
}
});