Skip to content

Commit

Permalink
Run QUnit tests on SauceLabs (#505)
Browse files Browse the repository at this point in the history
Run QUnit tests on SauceLabs against a set of browsers.
  • Loading branch information
bbrala authored Feb 17, 2017
1 parent f8c2373 commit 70b4d37
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 7 deletions.
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ env:
- GIT_NAME: "'Couscous auto deploy'"
- GIT_EMAIL: [email protected]
- GH_REF: github.com/swisnl/jQuery-contextMenu
- SAUCE_USERNAME: "bbrala-contextmenu"
- secure: XaE2bPODLwmzaNAKv9pA8mMiXJc8OrpyrO5tIGuOCwfQ+q7hx6Xa/tTcyn5+H2g+xYyJ0Qqv5+SDkDxbbgaVJLR1VEW15KEcZbD/3speqkg+yIC/oFxgbf1Ib01f0FowR2cw4/5Y2XzCM8CU7UxOLFGBDDCvM39Ab3UUl4uB/8g=
- secure: UOse3txRLxLQKsPVQf6OKZZP3c0nLaPJ+4G2vR/qJqBXCTTCQ84+9qx9ih/40FDFcjVXwabJsdn0EhkqDw4h50OGdc58V1UfSbk7g1RiuvvRakOPTK0J9h7bEkBPb7QQXCvAVfOZ81DN6l5lMjmH1tiC2T/h/MNOLHPXsbzXElg=

cache:
directories:
- node_modules
- documentation/vendor

matrix:
include:
- env: JQUERY=1 php=5.5
Expand All @@ -18,10 +26,10 @@ matrix:


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

script: if [ "$JQUERY" ] ; then npm test ; else /home/travis/.composer/vendor/bin/couscous travis-auto-deploy --php-version=5.5 ; fi
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

deploy:
provider: npm
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ $.contextMenu is a management facility for - you guessed it - context menus. It
[documentation](http://swisnl.github.io/jQuery-contextMenu/docs.html)


[![Sauce Test Status](https://saucelabs.com/browser-matrix/bbrala-contextmenu.svg)](https://saucelabs.com/u/bbrala-contextmenu)

## Dependencies ##

* jQuery >=1.8.2
Expand Down
88 changes: 88 additions & 0 deletions karma-saucelabs.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

module.exports = function (config) {
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
console.log('Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.')
process.exit(1)
}

var testedCapabilities = {};
var browsers = [];

var capabilities = {
'Windows 7': {
'internet explorer': ['11', '10', '9'],
},
'Windows 10': {
'firefox': ['latest', 'latest-1', 'latest-2'],
'chrome': ['latest', 'latest-1', 'latest-2'],
'MicrosoftEdge': ['latest']
},
'macOS 10.12': {
'firefox': ['latest'],
'chrome': ['latest'],
'safari': ['latest']
}
};

var buildDate = new Date().toISOString();
for (var osVersion in capabilities) {
for (var browserKey in capabilities[osVersion]) {
for(var i=0; i< capabilities[osVersion][browserKey].length; i++){
var browserVersion = capabilities[osVersion][browserKey][i];
testedCapabilities[osVersion + ' ' + browserKey + ' ' + browserVersion] = {
base: 'SauceLabs',
platform: osVersion,
browserName: browserKey,
version: browserVersion,
name: osVersion + ' ' + browserKey + ' ' + browserVersion,
build: buildDate
};
}


if(browsers.indexOf(browserKey) == -1){
browsers.push(browsers);
}
}
}

config.set({
basePath: '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['qunit'],


// list of files / patterns to load in the browser
files: [

// dependencies
{ pattern: 'node_modules/jquery/dist/jquery.js', watched: false, served: true, included: true },
{ pattern: 'src/jquery.ui.position.js', watched: false, served: true, included: true },
{ pattern: 'src/jquery.contextMenu.js', watched: false, served: true, included: true },

// test modules
'test/unit/*.js'
],


reporters: ['dots', 'saucelabs'],
port: 9876,
colors: true,
sauceLabs: {
testName: 'jQuery contextMenu saucelabs',
recordScreenshots: false,
connectOptions: {
port: 5757,
logfile: 'sauce_connect.log'
},
public: 'public'
},
// Increase timeout in case connection in CI is slow
captureTimeout: 600000,
customLaunchers: testedCapabilities,
browsers: Object.keys(testedCapabilities),
singleRun: true
})
}
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
reporters: ['dots'],


// web server port
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"doctoc": "^1.2.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.1",
"gulp-clean-css": "^2.0.13",
"gulp-concat": "~2.6.0",
"gulp-consolidate": "^0.2.0",
"gulp-csscomb": "^3.0.8",
Expand All @@ -25,7 +26,6 @@
"gulp-jscs": "^3.0.2",
"gulp-jshint": "^2.0.2",
"gulp-load-plugins": "^1.3.0",
"gulp-clean-css": "^2.0.13",
"gulp-qunit": "^1.5.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
Expand All @@ -37,6 +37,7 @@
"karma-chrome-launcher": "^2.0.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-qunit": "^1.2.1",
"karma-sauce-launcher": "^1.1.0",
"lodash": "^4.16.4",
"qunitjs": "^2.0.1",
"wdio-dot-reporter": "0.0.6",
Expand Down Expand Up @@ -85,6 +86,7 @@
"scripts": {
"test": "npm run test-unit",
"test-unit": "./node_modules/karma/bin/karma start",
"test-sauce": "./node_modules/.bin/wdio wdio.conf.js"
"test-sauce": "./node_modules/karma/bin/karma start karma-saucelabs.conf.js",
"test-accept": "./node_modules/.bin/wdio wdio.conf.js"
}
}
2 changes: 0 additions & 2 deletions test/unit/test-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function testQUnit(name, itemClickEvent, triggerEvent) {
});
// before each test
function createContextMenu(items, classname) {
console.info('Creating menu');
if(typeof(classname) == 'undefined'){
classname = 'context-menu';
}
Expand Down Expand Up @@ -55,7 +54,6 @@ function testQUnit(name, itemClickEvent, triggerEvent) {

// after each test
function destroyContextMenuAndCleanup() {
console.info('Destroying menu');
$.contextMenu('destroy');

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

0 comments on commit 70b4d37

Please sign in to comment.