Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 97b2b41

Browse files
test: Add testing for window.optimizelySdk (optimizely#193)
1 parent 45f6794 commit 97b2b41

File tree

7 files changed

+441
-147
lines changed

7 files changed

+441
-147
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ env:
1717
- secure: U0GGZw46rJowBtH9gVluIrerB40u2b3uZpH0HsOdLlsXCCaTVk4JXX/JPVPashWAFLC7Enk3UOE4ofeEpVd0wbG6CxtG9/gklc2U2tvkqsdPpFZKaRrXoUzCyyPOmHEC2mXDXctbrncmttM4APaceRfbdTBEZIIfyLJadomjWylA61szFE9IZjvJpiwJO2xa5HI9GVRu3yXJci+riJux+JsDmfJ1hNwv3waMeeg/scddUH0hfgq69ftGs8cpMlYiO20eh32S7uPF7/IJTH1fDJjVKYQZwpypkF6AeI+od5CFTY1ajb25eaBNXThLS0Bo9ZJE/8Sogvon21dEJkt/ClY6R341InbAFXZvz7jyQAisvh0I4zxcu0VUCfh7bEUl6GXMO8VJnyxHEfqB+AIT2RoMXckkhulwiNUsJYH1yJ8mjnLvZq85mWBCp4n4jg0K6Wf46lHpjnHOVpLyLyoFGfiPf90AQVL02AJ3/ia8RkMuj0Ax+AGtiTC/+wy7dsDQOif/VpBNJcx/RciQ24mYOGzAMh4GsUWnXaZ9vXSxliogVNrmIefK5invJ0omv9pIx8NZHTHYGaulh4w6JsliiEq2kH78SlyvSrcsFGTwCY97LLaxiLm/75/Zf+F7LajKC23Fbtnj/LQizitFZqGMJ09DnR52krBAeultqRq8QLM=
1818
matrix:
1919
include:
20-
- name: Cross-browser unit tests
20+
- name: Cross-browser and umd unit tests
2121
node_js: '10'
22-
script: npm run test-xbrowser
22+
script: npm run test-ci
2323
before_install: cd packages/optimizely-sdk
2424
install: npm install
2525
addons:
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/**
2+
* Copyright 2018, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Karma base configuration
18+
module.exports = {
19+
// base path that will be used to resolve all patterns (eg. files, exclude)
20+
basePath: '',
21+
22+
//plugins
23+
plugins: ['karma-mocha', 'karma-webpack', require('karma-browserstack-launcher')],
24+
25+
webpack: {
26+
mode: 'production',
27+
},
28+
29+
//browserStack setup
30+
browserStack: {
31+
username: process.env.BROWSER_STACK_USERNAME,
32+
accessKey: process.env.BROWSER_STACK_ACCESS_KEY
33+
},
34+
35+
// to avoid DISCONNECTED messages when connecting to BrowserStack
36+
browserDisconnectTimeout: 10000, // default 2000
37+
browserDisconnectTolerance: 1, // default 0
38+
browserNoActivityTimeout: 4 * 60 * 1000, //default 10000
39+
captureTimeout: 4 * 60 * 1000, //default 60000
40+
41+
// define browsers
42+
customLaunchers: {
43+
bs_chrome_mac: {
44+
base: 'BrowserStack',
45+
browser: 'chrome',
46+
browser_version: '21.0',
47+
os: 'OS X',
48+
os_version: 'Mountain Lion'
49+
},
50+
bs_edge: {
51+
base: 'BrowserStack',
52+
os: 'Windows',
53+
os_version: '10',
54+
browser: 'edge',
55+
device: null,
56+
browser_version: '15.0'
57+
},
58+
bs_firefox_mac: {
59+
base: 'BrowserStack',
60+
browser: 'firefox',
61+
browser_version: '21.0',
62+
os: 'OS X',
63+
os_version: 'Mountain Lion'
64+
},
65+
bs_ie: {
66+
base: 'BrowserStack',
67+
os: 'Windows',
68+
os_version: '7',
69+
browser: 'ie',
70+
device: null,
71+
browser_version: '10.0'
72+
},
73+
bs_iphone6: {
74+
base: 'BrowserStack',
75+
device: 'iPhone 6',
76+
os: 'ios',
77+
os_version: '8.3'
78+
},
79+
bs_opera_mac: {
80+
base: 'BrowserStack',
81+
browser: 'opera',
82+
browser_version: '37',
83+
os: 'OS X',
84+
os_version: 'Mountain Lion'
85+
},
86+
bs_safari: {
87+
base: 'BrowserStack',
88+
os: 'OS X',
89+
os_version: 'Mountain Lion',
90+
browser: 'safari',
91+
device: null,
92+
browser_version: '6.2'
93+
}
94+
},
95+
96+
browsers: ['bs_chrome_mac', 'bs_edge', 'bs_firefox_mac', 'bs_ie', 'bs_iphone6', 'bs_opera_mac', 'bs_safari'],
97+
98+
// frameworks to use
99+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
100+
frameworks: ['mocha'],
101+
102+
// list of files to exclude
103+
exclude: [
104+
],
105+
106+
107+
// preprocess matching files before serving them to the browser
108+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
109+
preprocessors: {
110+
'./lib/**/*tests.js': ['webpack']
111+
},
112+
113+
114+
// test results reporter to use
115+
// possible values: 'dots', 'progress'
116+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
117+
reporters: ['progress'],
118+
119+
120+
// web server port
121+
port: 9876,
122+
123+
124+
// enable / disable colors in the output (reporters and logs)
125+
colors: true,
126+
127+
128+
// enable / disable watching file and executing tests whenever any file changes
129+
autoWatch: false,
130+
131+
// Continuous Integration mode
132+
// if true, Karma captures browsers, runs the tests and exits
133+
singleRun: true,
134+
135+
// Concurrency level
136+
// how many browser should be started simultaneous
137+
concurrency: Infinity
138+
}
Lines changed: 22 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,33 @@
1-
// Karma configuration
2-
// Generated on Wed May 24 2017 14:10:20 GMT-0700 (PDT)
1+
/**
2+
* Copyright 2018, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Karma configuration for cross-browser testing
18+
const baseConfig = require('./karma.base.conf.js')
319

420
module.exports = function(config) {
521
config.set({
22+
...baseConfig,
623

7-
// base path that will be used to resolve all patterns (eg. files, exclude)
8-
basePath: '',
9-
10-
//plugins
11-
plugins: ['karma-mocha', 'karma-webpack', require('karma-browserstack-launcher')],
12-
13-
webpack: {
14-
mode: 'production',
15-
},
16-
17-
//browserStack setup
18-
browserStack: {
19-
username: process.env.BROWSER_STACK_USERNAME,
20-
accessKey: process.env.BROWSER_STACK_ACCESS_KEY
21-
},
22-
23-
// to avoid DISCONNECTED messages when connecting to BrowserStack
24-
browserDisconnectTimeout: 10000, // default 2000
25-
browserDisconnectTolerance: 1, // default 0
26-
browserNoActivityTimeout: 4 * 60 * 1000, //default 10000
27-
captureTimeout: 4 * 60 * 1000, //default 60000
28-
29-
// define browsers
30-
customLaunchers: {
31-
bs_chrome_mac: {
32-
base: 'BrowserStack',
33-
browser: 'chrome',
34-
browser_version: '21.0',
35-
os: 'OS X',
36-
os_version: 'Mountain Lion'
37-
},
38-
bs_edge: {
39-
base: 'BrowserStack',
40-
os: 'Windows',
41-
os_version: '10',
42-
browser: 'edge',
43-
device: null,
44-
browser_version: '15.0'
45-
},
46-
bs_firefox_mac: {
47-
base: 'BrowserStack',
48-
browser: 'firefox',
49-
browser_version: '21.0',
50-
os: 'OS X',
51-
os_version: 'Mountain Lion'
52-
},
53-
bs_ie: {
54-
base: 'BrowserStack',
55-
os: 'Windows',
56-
os_version: '7',
57-
browser: 'ie',
58-
device: null,
59-
browser_version: '10.0'
60-
},
61-
bs_iphone6: {
62-
base: 'BrowserStack',
63-
device: 'iPhone 6',
64-
os: 'ios',
65-
os_version: '8.3'
66-
},
67-
bs_opera_mac: {
68-
base: 'BrowserStack',
69-
browser: 'opera',
70-
browser_version: '37',
71-
os: 'OS X',
72-
os_version: 'Mountain Lion'
73-
},
74-
bs_safari: {
75-
base: 'BrowserStack',
76-
os: 'OS X',
77-
os_version: 'Mountain Lion',
78-
browser: 'safari',
79-
device: null,
80-
browser_version: '6.2'
81-
}
82-
},
83-
84-
browsers: ['bs_chrome_mac', 'bs_edge', 'bs_firefox_mac', 'bs_ie', 'bs_iphone6', 'bs_opera_mac', 'bs_safari'],
85-
86-
// frameworks to use
87-
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
88-
frameworks: ['mocha'],
89-
24+
// level of logging
25+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
26+
logLevel: config.LOG_INFO,
9027

9128
// list of files / patterns to load in the browser
9229
files: [
9330
'./lib/index.browser.tests.js'
9431
],
95-
96-
97-
// list of files to exclude
98-
exclude: [
99-
],
100-
101-
102-
// preprocess matching files before serving them to the browser
103-
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
104-
preprocessors: {
105-
'./lib/**/*tests.js': ['webpack']
106-
},
107-
108-
109-
// test results reporter to use
110-
// possible values: 'dots', 'progress'
111-
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
112-
reporters: ['progress'],
113-
114-
115-
// web server port
116-
port: 9876,
117-
118-
119-
// enable / disable colors in the output (reporters and logs)
120-
colors: true,
121-
122-
123-
// level of logging
124-
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
125-
logLevel: config.LOG_INFO,
126-
127-
128-
// enable / disable watching file and executing tests whenever any file changes
129-
autoWatch: false,
130-
131-
// Continuous Integration mode
132-
// if true, Karma captures browsers, runs the tests and exits
133-
singleRun: true,
134-
135-
// Concurrency level
136-
// how many browser should be started simultaneous
137-
concurrency: Infinity
13832
});
13933
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2018, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Karma configuration for UMD bundle testing
18+
const baseConfig = require('./karma.base.conf.js')
19+
20+
module.exports = function(config) {
21+
config.set({
22+
...baseConfig,
23+
24+
// level of logging
25+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
26+
logLevel: config.LOG_INFO,
27+
28+
// list of files / patterns to load in the browser
29+
files: [
30+
'./dist/optimizely.browser.umd.min.js',
31+
'./lib/index.browser.umdtests.js'
32+
],
33+
});
34+
};

0 commit comments

Comments
 (0)