Skip to content

Commit

Permalink
use karma runner on saucelabs
Browse files Browse the repository at this point in the history
and drop qunit infrastructure at all
  • Loading branch information
outsideris committed Dec 6, 2015
1 parent 588889a commit 71cb59a
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 234 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ before_script:
- npm --version
- npm install -g grunt-cli
script:
- grunt test --verbose
- grunt test-travis --verbose
- if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then grunt saucelabs-test; fi
- grunt karma:travis
- grunt coveralls:travis
before_deploy:
- npm install
Expand Down
105 changes: 62 additions & 43 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,51 @@ module.exports = function (grunt) {
return data;
};

var customLaunchers = {
'SL_IE8': {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '8.0',
platform: 'windows XP'
},
'SL_IE9': {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '9.0',
platform: 'windows 7'
},
'SL_IE10': {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '10.0',
platform: 'windows 8'
},
'SL_IE11': {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '11.0',
platform: 'windows 8.1'
},
'SL_CHROME': {
base: 'SauceLabs',
browserName: 'chrome',
version: '43',
platform: 'windows 8'
},
'SL_FIREFOX': {
base: 'SauceLabs',
browserName: 'firefox',
version: '38',
  platform: 'windows 8'
},
'SL_SAFARI': {
base: 'SauceLabs',
browserName: 'safari',
  version: '8.0',
  platform: 'OS X 10.10'
}
};

grunt.initConfig({
// package File
pkg: grunt.file.readJSON('package.json'),
Expand Down Expand Up @@ -132,47 +177,6 @@ module.exports = function (grunt) {
}
},

'saucelabs-qunit': {
'all': {
options: {
urls: ['http://localhost:3000/test/unit.html'],
build: process.env.TRAVIS_BUILD_NUMBER,
tags: [process.env.TRAVIS_BRANCH, process.env.TRAVIS_PULL_REQUEST],
browsers: [{
browserName: 'internet explorer',
version: '8.0',
platform: 'windows XP'
}, {
browserName: 'internet explorer',
version: '9.0',
platform: 'windows 7'
}, {
browserName: 'internet explorer',
version: '10.0',
platform: 'windows 8'
}, {
browserName: 'internet explorer',
version: '11.0',
platform: 'windows 8.1'
}, {
browserName: 'chrome',
version: '43',
platform: 'windows 8'
}, {
     browserName: 'firefox',
     version: '38',
     platform: 'windows 8'
   }, {
     browserName: 'safari',
     version: '8.0',
     platform: 'OS X 10.10'
   }],
testname: 'unit test for summernote',
'public': 'public'
}
}
},

karma: {
options: {
configFile: './test/karma.conf.js'
Expand All @@ -185,6 +189,18 @@ module.exports = function (grunt) {
singleRun: true,
browsers: ['PhantomJS'],
reporters: ['progress', 'coverage']
},
saucelabs: {
reporters: ['saucelabs'],
sauceLabs: {
testName: 'unit tests for summernote',
build: process.env.TRAVIS_BUILD_NUMBER,
tags: [process.env.TRAVIS_BRANCH, process.env.TRAVIS_PULL_REQUEST]
},
captureTimeout: 120000,
customLaunchers: customLaunchers,
browsers: Object.keys(customLaunchers),
singleRun: true
}
},

Expand All @@ -208,10 +224,13 @@ module.exports = function (grunt) {
grunt.registerTask('server', ['connect', 'watch']);

// test: unit test on test folder
grunt.registerTask('test', ['jshint', 'qunit']);
grunt.registerTask('test', ['jshint', 'karma:all']);

// test: unit test on travis
grunt.registerTask('test-travis', ['jshint', 'karma:travis']);

// test: saucelabs test
grunt.registerTask('saucelabs-test', ['connect', 'saucelabs-qunit']);
grunt.registerTask('saucelabs-test', ['karma:saucelabs']);

// dist: make dist files
grunt.registerTask('dist', ['build', 'test', 'uglify', 'recess', 'compress']);
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"grunt-contrib-compress": "*",
"grunt-contrib-connect": "*",
"grunt-contrib-jshint": "0.7.2",
"grunt-contrib-qunit": "0.5.2",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "*",
"grunt-coveralls": "^1.0.0",
Expand All @@ -38,9 +37,9 @@
"karma-mocha": "^0.2.0",
"karma-opera-launcher": "^0.2.0",
"karma-phantomjs-launcher": "^0.2.0",
"karma-qunit": "^0.1.5",
"karma-requirejs": "^0.2.2",
"karma-safari-launcher": "^0.1.1",
"karma-sauce-launcher": "^0.2.14",
"load-grunt-tasks": "0.2.0",
"open": "0.0.4",
"phantomjs": "^1.9.17",
Expand Down
2 changes: 1 addition & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function (config) {

config.set({
basePath: '../',
frameworks: ['requirejs', 'mocha', 'qunit'],
frameworks: ['requirejs', 'mocha'],
exclude: [],
reporters: ['progress', 'coverage'],
port: 9876,
Expand Down
77 changes: 1 addition & 76 deletions test/test-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,80 +30,5 @@ requirejs.config({
// ask Require.js to load these files (all our tests)
deps: tests,

callback: function () {
require([
'summernote/base/core/agent',
'../../test/unit/func.spec',
'../../test/unit/key.spec',
'../../test/unit/dom.spec',
'../../test/unit/list.spec',
'../../test/unit/range.spec',
'../../test/unit/style.spec'
], function (agent, funcSpec, keySpec, domSpec, listSpec, rangeSpec, styleSpec) {

var helper = {
equalsToUpperCase: function (actual, expected, comment) {
actual = actual.toUpperCase();
expected = expected.toUpperCase();

// [workaround] IE8-10 use   instead of bogus br
if (agent.isMSIE && agent.browserVersion < 11) {
expected = expected.replace(/<BR>/g, '&NBSP;');
}

// [workaround] IE8 actual markup has newline between tags
if (agent.isMSIE && agent.browserVersion < 9) {
actual = actual.replace(/\r\n/g, '');
}

equal(actual, expected, comment);
}
};

module('unit/func');
funcSpec(helper);
module('unit/key');
keySpec(helper);
module('unit/dom');
domSpec(helper);
module('unit/list');
listSpec(helper);
module('unit/range');
rangeSpec(helper);
module('unit/styleSpec');
styleSpec();
});


/* jshint ignore:start */
var log = [];
QUnit.done(function (test_results) {
var tests = [];
for(var i = 0, len = log.length; i < len; i++) {
var details = log[i];
tests.push({
name: details.name,
result: details.result,
expected: details.expected,
actual: details.actual,
source: details.source
});
}
test_results.tests = tests;

window.global_test_results = test_results;
});
QUnit.testStart(function(testDetails){
QUnit.log(function(details){
if (!details.result) {
details.name = testDetails.name;
log.push(details);
}
});
});
/* jshint ignore:end */

// start test run, once Require.js is done
window.__karma__.start();
}
callback: window.__karma__.start
});
16 changes: 0 additions & 16 deletions test/unit.html

This file was deleted.

94 changes: 0 additions & 94 deletions test/unit.js

This file was deleted.

0 comments on commit 71cb59a

Please sign in to comment.