Permalink
Browse files

Add cross browser testing (#3198)

* add sauce runner

* improve mocha results processing

* update cross browser testing

* cleanup

* revert livereload removing, update easy-sauce version

* cleanup
  • Loading branch information...
1 parent ab472b9 commit 6a72aff6172848076dd5fe8a5c4cc0ceaf17e9e0 @denar90 denar90 committed with paulfalgout Oct 25, 2016
Showing with 84 additions and 14 deletions.
  1. +2 −2 .travis.yml
  2. +51 −9 gulp/test-browser.js
  3. +3 −1 package.json
  4. +3 −0 readme.md
  5. +24 −1 test/setup/browser.js
  6. +1 −1 test/setup/setup.js
View
@@ -8,6 +8,6 @@ before_install:
install:
- npm install && npm install travis-ci
after_success:
- - npm run-script coveralls
+ - npm run-script coveralls && npm run-script test-cross-browser
- if [[ $TRAVIS_BRANCH = "master" ]] && [[ $TRAVIS_PULL_REQUEST = "false" ]]; then node trigger-deploy-mn-com.js; fi
-
+
View
@@ -1,5 +1,6 @@
import gulp from 'gulp';
import livereload from 'gulp-livereload';
+import easySauce from 'easy-sauce';
import { rollup } from 'rollup';
import babel from 'rollup-plugin-babel';
@@ -10,6 +11,23 @@ import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import opn from 'opn';
+const sauceConf = {
+ name: 'Marionette.js',
+ username: process.env.SAUCE_USERNAME,
+ key: process.env.SAUCE_ACCESS_KEY,
+ testPath: '/test/runner.html',
+ port: '8080',
+ framework: 'mocha',
+ platforms: [
+ ['Windows 10', 'MicrosoftEdge', 'latest'],
+ ['Windows 10', 'chrome', 'latest'],
+ ['OS X 10.11', 'chrome', 'latest'],
+ ['OS X 10.11', 'firefox', "latest"],
+ ['OS X 10.11', 'safari', '9.0']
+ ],
+ service: 'sauce-connect'
+};
+
function bundle() {
return rollup({
entry: ['./test/setup/browser.js', './test/unit/**/*.js'],
@@ -26,14 +44,12 @@ function bundle() {
exclude: 'node_modules/**'
})
]
- }).then(function (bundle) {
- return bundle.write({
- format: 'iife',
- sourceMap: true,
- moduleName: 'MnTests',
- dest: './tmp/__spec-build.js'
- });
- }).then(livereload.changed('./tmp/__spec-build.js'));
+ }).then(bundle => bundle.write({
+ format: 'iife',
+ sourceMap: true,
+ moduleName: 'MnTests',
+ dest: './tmp/__spec-build.js'
+ }).then(livereload.reload('./tmp/__spec-build.js')));
}
function browserWatch() {
@@ -42,6 +58,32 @@ function browserWatch() {
gulp.watch(['src/**/*.js', 'test/**/*.js'], ['browser-bundle']);
}
-gulp.task('browser-bundle', ['lint-src', 'lint-test'], bundle);
+function sauceRunner() {
+ easySauce(sauceConf)
+ .on('message', message => {
+ // A message has been emitted, inform the user.
+ console.log(message);
+ })
+ .on('update', job => {
+ // A job's status has been updated
+ console.log(job.status);
+ })
+ .on('done', (passed, jobs) => {
+ // All tests have completed!
+ if (passed) {
+ console.log('All tests passed!');
+ } else {
+ console.log('Oops, there were failures:\n' + jobs);
+ }
+ })
+ .on('error', error => {
+ // An error occurred at some point running the tests.
+ throw new Error(error.message);
+ });
+}
+
+gulp.task('browser-bundle', ['lint-src', 'lint-test'], bundle);
gulp.task('test-browser', ['browser-bundle'], browserWatch);
+
+gulp.task('test-cross-browser', ['browser-bundle'], sauceRunner);
View
@@ -22,7 +22,8 @@
"coverage": "gulp coverage",
"coveralls": "gulp coveralls",
"test": "gulp",
- "test-browser": "gulp test-browser"
+ "test-browser": "gulp test-browser",
+ "test-cross-browser": "gulp test-cross-browser"
},
"author": {
"name": "Derick Bailey",
@@ -54,6 +55,7 @@
"backbone": "1.2.1 - 1.3.x",
"chai": "3.5.0",
"chai-jq": "0.0.9",
+ "easy-sauce": "0.4.1",
"eslint": "3.7.1",
"gulp": "3.9.1",
"gulp-coveralls": "0.1.4",
View
@@ -14,6 +14,9 @@
<img src='https://badges.gitter.im/Join%20Chat.svg' alt='Gitter Chat' />
</a>
</p>
+<p align="center">
+ <img src='https://saucelabs.com/browser-matrix/marionettejs.svg' alt'Cross Browser Tesing' />
+</p>
## Marionette v3
View
@@ -4,6 +4,29 @@ global.mocha.setup('bdd');
global.onload = function() {
global.mocha.checkLeaks();
global.mocha.globals(Object.keys(mochaGlobals));
- global.mocha.run();
+
+ var runner = global.mocha.run();
+
+ mochaResults(runner);
require('./setup')();
};
+
+var mochaResults = function(runner) {
+ var failedTests = [];
+
+ runner.on('end', function() {
+ global.mochaResults = runner.stats;
+ global.mochaResults.reports = failedTests;
+ });
+
+ runner.on('fail', function(test, err) {
+ failedTests.push({
+ title: test.title,
+ fullTitle: test.fullTitle(),
+ error: {
+ message: err.message,
+ stack: err.stack
+ }
+ });
+ });
+}
View
@@ -1,4 +1,4 @@
-module.exports = function() {
+module.exports = function(mochaRunner) {
var _ = require('underscore');
var Backbone = require('backbone');
var jQuery = require('jquery');

0 comments on commit 6a72aff

Please sign in to comment.