Skip to content

Commit 70b4d37

Browse files
authored
Run QUnit tests on SauceLabs (#505)
Run QUnit tests on SauceLabs against a set of browsers.
1 parent f8c2373 commit 70b4d37

File tree

6 files changed

+105
-7
lines changed

6 files changed

+105
-7
lines changed

.travis.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ env:
66
- GIT_NAME: "'Couscous auto deploy'"
77
- GIT_EMAIL: [email protected]
88
- GH_REF: github.com/swisnl/jQuery-contextMenu
9+
- SAUCE_USERNAME: "bbrala-contextmenu"
910
- secure: XaE2bPODLwmzaNAKv9pA8mMiXJc8OrpyrO5tIGuOCwfQ+q7hx6Xa/tTcyn5+H2g+xYyJ0Qqv5+SDkDxbbgaVJLR1VEW15KEcZbD/3speqkg+yIC/oFxgbf1Ib01f0FowR2cw4/5Y2XzCM8CU7UxOLFGBDDCvM39Ab3UUl4uB/8g=
11+
- secure: UOse3txRLxLQKsPVQf6OKZZP3c0nLaPJ+4G2vR/qJqBXCTTCQ84+9qx9ih/40FDFcjVXwabJsdn0EhkqDw4h50OGdc58V1UfSbk7g1RiuvvRakOPTK0J9h7bEkBPb7QQXCvAVfOZ81DN6l5lMjmH1tiC2T/h/MNOLHPXsbzXElg=
12+
13+
cache:
14+
directories:
15+
- node_modules
16+
- documentation/vendor
17+
1018
matrix:
1119
include:
1220
- env: JQUERY=1 php=5.5
@@ -18,10 +26,10 @@ matrix:
1826

1927

2028
install:
21-
- if [ "$JQUERY" ] ; then nvm install 6 && npm install && npm install jquery@$JQUERY && npm test ; fi
29+
- if [ "$JQUERY" ] ; then nvm install 6 && npm install && npm install jquery@$JQUERY ; fi
2230
- if [ "$DOCUMENTATION" ] ; then cd documentation && composer global require couscous/couscous ; fi
2331

24-
script: if [ "$JQUERY" ] ; then npm test ; else /home/travis/.composer/vendor/bin/couscous travis-auto-deploy --php-version=5.5 ; fi
32+
script: if [ "$JQUERY" ] ; then npm test && npm run test-sauce ; else /home/travis/.composer/vendor/bin/couscous travis-auto-deploy --php-version=5.5 ; fi
2533

2634
deploy:
2735
provider: npm

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ $.contextMenu is a management facility for - you guessed it - context menus. It
99
[documentation](http://swisnl.github.io/jQuery-contextMenu/docs.html)
1010

1111

12+
[![Sauce Test Status](https://saucelabs.com/browser-matrix/bbrala-contextmenu.svg)](https://saucelabs.com/u/bbrala-contextmenu)
13+
1214
## Dependencies ##
1315

1416
* jQuery >=1.8.2

karma-saucelabs.conf.js

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
2+
module.exports = function (config) {
3+
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
4+
console.log('Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.')
5+
process.exit(1)
6+
}
7+
8+
var testedCapabilities = {};
9+
var browsers = [];
10+
11+
var capabilities = {
12+
'Windows 7': {
13+
'internet explorer': ['11', '10', '9'],
14+
},
15+
'Windows 10': {
16+
'firefox': ['latest', 'latest-1', 'latest-2'],
17+
'chrome': ['latest', 'latest-1', 'latest-2'],
18+
'MicrosoftEdge': ['latest']
19+
},
20+
'macOS 10.12': {
21+
'firefox': ['latest'],
22+
'chrome': ['latest'],
23+
'safari': ['latest']
24+
}
25+
};
26+
27+
var buildDate = new Date().toISOString();
28+
for (var osVersion in capabilities) {
29+
for (var browserKey in capabilities[osVersion]) {
30+
for(var i=0; i< capabilities[osVersion][browserKey].length; i++){
31+
var browserVersion = capabilities[osVersion][browserKey][i];
32+
testedCapabilities[osVersion + ' ' + browserKey + ' ' + browserVersion] = {
33+
base: 'SauceLabs',
34+
platform: osVersion,
35+
browserName: browserKey,
36+
version: browserVersion,
37+
name: osVersion + ' ' + browserKey + ' ' + browserVersion,
38+
build: buildDate
39+
};
40+
}
41+
42+
43+
if(browsers.indexOf(browserKey) == -1){
44+
browsers.push(browsers);
45+
}
46+
}
47+
}
48+
49+
config.set({
50+
basePath: '',
51+
52+
// frameworks to use
53+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
54+
frameworks: ['qunit'],
55+
56+
57+
// list of files / patterns to load in the browser
58+
files: [
59+
60+
// dependencies
61+
{ pattern: 'node_modules/jquery/dist/jquery.js', watched: false, served: true, included: true },
62+
{ pattern: 'src/jquery.ui.position.js', watched: false, served: true, included: true },
63+
{ pattern: 'src/jquery.contextMenu.js', watched: false, served: true, included: true },
64+
65+
// test modules
66+
'test/unit/*.js'
67+
],
68+
69+
70+
reporters: ['dots', 'saucelabs'],
71+
port: 9876,
72+
colors: true,
73+
sauceLabs: {
74+
testName: 'jQuery contextMenu saucelabs',
75+
recordScreenshots: false,
76+
connectOptions: {
77+
port: 5757,
78+
logfile: 'sauce_connect.log'
79+
},
80+
public: 'public'
81+
},
82+
// Increase timeout in case connection in CI is slow
83+
captureTimeout: 600000,
84+
customLaunchers: testedCapabilities,
85+
browsers: Object.keys(testedCapabilities),
86+
singleRun: true
87+
})
88+
}

karma.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = function(config) {
4040
// test results reporter to use
4141
// possible values: 'dots', 'progress'
4242
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
43-
reporters: ['progress'],
43+
reporters: ['dots'],
4444

4545

4646
// web server port

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"doctoc": "^1.2.0",
1515
"gulp": "^3.9.1",
1616
"gulp-autoprefixer": "^3.1.1",
17+
"gulp-clean-css": "^2.0.13",
1718
"gulp-concat": "~2.6.0",
1819
"gulp-consolidate": "^0.2.0",
1920
"gulp-csscomb": "^3.0.8",
@@ -25,7 +26,6 @@
2526
"gulp-jscs": "^3.0.2",
2627
"gulp-jshint": "^2.0.2",
2728
"gulp-load-plugins": "^1.3.0",
28-
"gulp-clean-css": "^2.0.13",
2929
"gulp-qunit": "^1.5.0",
3030
"gulp-rename": "^1.2.2",
3131
"gulp-replace": "^0.5.4",
@@ -37,6 +37,7 @@
3737
"karma-chrome-launcher": "^2.0.0",
3838
"karma-phantomjs-launcher": "^1.0.2",
3939
"karma-qunit": "^1.2.1",
40+
"karma-sauce-launcher": "^1.1.0",
4041
"lodash": "^4.16.4",
4142
"qunitjs": "^2.0.1",
4243
"wdio-dot-reporter": "0.0.6",
@@ -85,6 +86,7 @@
8586
"scripts": {
8687
"test": "npm run test-unit",
8788
"test-unit": "./node_modules/karma/bin/karma start",
88-
"test-sauce": "./node_modules/.bin/wdio wdio.conf.js"
89+
"test-sauce": "./node_modules/karma/bin/karma start karma-saucelabs.conf.js",
90+
"test-accept": "./node_modules/.bin/wdio wdio.conf.js"
8991
}
9092
}

test/unit/test-events.js

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ function testQUnit(name, itemClickEvent, triggerEvent) {
1212
});
1313
// before each test
1414
function createContextMenu(items, classname) {
15-
console.info('Creating menu');
1615
if(typeof(classname) == 'undefined'){
1716
classname = 'context-menu';
1817
}
@@ -55,7 +54,6 @@ function testQUnit(name, itemClickEvent, triggerEvent) {
5554

5655
// after each test
5756
function destroyContextMenuAndCleanup() {
58-
console.info('Destroying menu');
5957
$.contextMenu('destroy');
6058

6159
// clean up `#qunit-fixture` when testing in karma runner

0 commit comments

Comments
 (0)