Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Add Browserify build for browser testing in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ericf committed Jan 23, 2015
1 parent c1cc0eb commit cabaca1
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,21 @@ module.exports = function (grunt) {
}
},

browserify: {
test: {
src : 'tests/browserify/app.js',
dest: 'tmp/browserify/app.js'
}
},

'saucelabs-mocha': {
all: {
options: {
urls: ['http://127.0.0.1:9999/tests/index.html'],
urls: [
'http://127.0.0.1:9999/tests/index.html',
'http://127.0.0.1:9999/tests/browserify/index.html'
],

build: process.env.TRAVIS_BUILD_NUMBER,
sauceConfig: {
'record-video': false,
Expand Down Expand Up @@ -223,14 +234,16 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-bundle-jsnext-lib');
grunt.loadNpmTasks('grunt-benchmark');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-bundle-jsnext-lib');
grunt.loadNpmTasks('grunt-extract-cldr-data');
grunt.loadNpmTasks('grunt-json-remove-fields');
grunt.loadNpmTasks('grunt-saucelabs');
grunt.loadNpmTasks('grunt-contrib-connect');

grunt.registerTask('sauce', [
'browserify',
'connect',
'saucelabs-mocha'
]);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"expect.js": "^0.3.1",
"grunt": "^0.4.5",
"grunt-benchmark": "^0.3.0",
"grunt-browserify": "^3.3.0",
"grunt-bundle-jsnext-lib": "^0.5.0",
"grunt-cli": "^0.1.13",
"grunt-contrib-clean": "^0.6.0",
Expand Down
4 changes: 4 additions & 0 deletions tests/browserify/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';

require('../../lib/locales');
window.IntlMessageFormat = require('../../');
50 changes: 50 additions & 0 deletions tests/browserify/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<title>Browserify Mocha Tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="../../node_modules/mocha/mocha.js"></script><!-- provides `describe` and `it` globals -->
<script src="../../node_modules/expect.js/index.js"></script><!-- provides `chai` global -->
<script src="../../node_modules/intl/Intl.complete.js"></script> <!-- provides `Intl` polyfill -->
<script src="../../tmp/browserify/app.js"></script><!-- provides `IntlMessageFormat` global -->
<script>mocha.setup('bdd')</script>
<script src="../index.js"></script>
<script>
(function () {
var runner = mocha.run();

var failedTests = [];
runner.on('end', function () {
window.mochaResults = runner.stats;
window.mochaResults.reports = failedTests;
});

function flattenTitles(test) {
var titles = [];
while (test.parent.title){
titles.push(test.parent.title);
test = test.parent;
}
return titles.reverse();
}

runner.on('fail', function (test, err) {

failedTests.push({
name: test.title,
result: false,
message: err && err.message,
stack: err && err.stack,
titles: flattenTitles(test)
});

});
}());
</script>
</body>
</html>

0 comments on commit cabaca1

Please sign in to comment.