Skip to content

Commit c23ba0c

Browse files
committed
test: add mobile browsers for testing
1 parent 7548f0b commit c23ba0c

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 'BrowserStack Mobile Test'
2+
on: [push, pull_request, workflow_dispatch]
3+
4+
jobs:
5+
browserstack-mobile-test:
6+
name: 'BrowserStack Mobile Test'
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: 'BrowserStack Env Setup'
10+
uses: browserstack/github-actions/setup-env@master
11+
with:
12+
username: ${{ secrets.BROWSERSTACK_USERNAME }}
13+
access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
14+
15+
- name: 'BrowserStack Local Tunnel Setup'
16+
uses: browserstack/github-actions/setup-local@master
17+
with:
18+
local-testing: start
19+
local-identifier: random
20+
21+
- name: 'Checkout the repository'
22+
uses: actions/checkout@v3
23+
24+
- name: 'Run NPM CI'
25+
run: npm ci
26+
27+
- name: Run Build IIFE
28+
run: npm run build:iife
29+
30+
- name: 'Run NPM build test bundle'
31+
run: npm run build:test-bundle
32+
33+
- name: 'Run Browserstack Mobile Tests'
34+
run: npm run test:browserstack-mobile
35+
36+
- name: 'BrowserStackLocal Stop'
37+
uses: browserstack/github-actions/setup-local@master
38+
with:
39+
local-testing: stop

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
"test": "npm run build && npm run build:test-bundle && cross-env DEBUG=false karma start test/karma.config.js",
4444
"test:browserstack": "karma start test/cross-browser-testing/browserstack.karma.config.js",
4545
"test:browserstack:debug": "cross-env DEBUG=true karma start test/cross-browser-testing/browserstack.karma.config.js",
46+
"test:browserstack-mobile": "karma start test/cross-browser-testing/browserstack.karma.mobile.config.js",
47+
"test:browserstack-mobile:debug": "cross-env DEBUG=true karma start test/cross-browser-testing/browserstack.karma.mobile.config.js",
4648
"test:debug": "cross-env DEBUG=true karma start test/karma.config.js",
4749
"test:stub": "cross-env TESTTYPE=stub ENVIRONMENT=prod rollup --config rollup.test.config.js && karma start test/stub/karma.stub.config.js",
4850
"test:integrations": "npm run test:requirejs && npm run test:integrations:cjs && npm run test:integrations:module",
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
const { DEBUG } = process.env;
2+
3+
const files = [
4+
'../lib/geomock.js',
5+
'../../dist/mparticle.js',
6+
'../test-bundle.js',
7+
];
8+
9+
let captureConsole = false;
10+
let browserConsoleLogOptions = {};
11+
12+
if (DEBUG === 'true') {
13+
browserConsoleLogOptions = {
14+
level: 'log',
15+
format: '%b %T: %m',
16+
terminal: true,
17+
};
18+
captureConsole = true;
19+
} else {
20+
browserConsoleLogOptions = {
21+
terminal: false,
22+
};
23+
}
24+
25+
const customLaunchers = {
26+
// Android Mobile Browsers
27+
bs_android_chrome: {
28+
base: 'BrowserStack',
29+
device: 'Google Pixel 8',
30+
os: 'android',
31+
os_version: '14.0',
32+
real_mobile: true,
33+
browser: 'chrome'
34+
},
35+
bs_android_firefox: {
36+
base: 'BrowserStack',
37+
device: 'Google Pixel 8',
38+
os: 'android',
39+
os_version: '14.0',
40+
real_mobile: true,
41+
browser: 'firefox'
42+
},
43+
bs_android_samsung: {
44+
base: 'BrowserStack',
45+
device: 'Samsung Galaxy S23',
46+
os: 'android',
47+
os_version: '13.0',
48+
real_mobile: true,
49+
browser: 'samsung'
50+
},
51+
52+
// iOS Mobile Browsers
53+
bs_ios_safari: {
54+
base: 'BrowserStack',
55+
device: 'iPhone 15 Pro',
56+
os: 'ios',
57+
os_version: '17',
58+
real_mobile: true,
59+
browser: 'safari'
60+
},
61+
bs_ios_chrome: {
62+
base: 'BrowserStack',
63+
device: 'iPhone 15 Pro',
64+
os: 'ios',
65+
os_version: '17',
66+
real_mobile: true,
67+
browser: 'chrome'
68+
},
69+
bs_ios_firefox: {
70+
base: 'BrowserStack',
71+
device: 'iPhone 15 Pro',
72+
os: 'ios',
73+
os_version: '17',
74+
real_mobile: true,
75+
browser: 'firefox'
76+
},
77+
};
78+
79+
module.exports = function(config) {
80+
config.set({
81+
browserStack: {
82+
username: process.env.BS_USERNAME,
83+
accessKey: process.env.BS_ACCESS_KEY,
84+
local: true,
85+
},
86+
autoWatch: false,
87+
customLaunchers,
88+
browsers: Object.keys(customLaunchers),
89+
frameworks: ['mocha', 'should'],
90+
files,
91+
reporters: ['progress', 'junit'],
92+
colors: true,
93+
singleRun: true,
94+
debug: true,
95+
logLevel: config.LOG_INFO,
96+
browserConsoleLogOptions,
97+
client: {
98+
captureConsole,
99+
mocha: {
100+
timeout: 10000
101+
}
102+
},
103+
junitReporter: {
104+
outputDir: 'reports/',
105+
outputFile: 'test-karma-mobile.xml',
106+
},
107+
browserDisconnectTimeout: 180000,
108+
browserDisconnectTolerance: 5,
109+
concurrency: 1,
110+
captureTimeout: 180000,
111+
browserNoActivityTimeout: 180000,
112+
});
113+
};

0 commit comments

Comments
 (0)