Browserify test suite
Our tests run in the browser and on node! Switching to browserify made this necessary.
This commit is contained in:
parent
2d245a0b26
commit
a4c0874668
23
gruntfile.js
23
gruntfile.js
|
@ -57,7 +57,10 @@ module.exports = function(grunt) {
|
|||
dest: "./dist/filer.js",
|
||||
options: {
|
||||
standalone: 'Filer',
|
||||
builtins: false
|
||||
browserifyOptions: {
|
||||
builtins: false,
|
||||
commondir: false
|
||||
}
|
||||
}
|
||||
},
|
||||
testVersion: {
|
||||
|
@ -65,14 +68,24 @@ module.exports = function(grunt) {
|
|||
dest: "./dist/filer-test.js",
|
||||
options: {
|
||||
standalone: 'Filer',
|
||||
builtins: false
|
||||
browserifyOptions: {
|
||||
builtins: false,
|
||||
commondir: false
|
||||
}
|
||||
}
|
||||
},
|
||||
testApp: {
|
||||
src: "./tests/index.js",
|
||||
dest: "./tests/test-bundle.js",
|
||||
options: {
|
||||
standalone: 'Filer test suite'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
shell: {
|
||||
mocha: {
|
||||
command: './node_modules/.bin/mocha --reporter list --no-exit tests/node-runner.js'
|
||||
command: './node_modules/.bin/mocha --reporter list --no-exit tests/index.js'
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -177,7 +190,7 @@ module.exports = function(grunt) {
|
|||
grunt.loadNpmTasks('grunt-browserify');
|
||||
|
||||
grunt.registerTask('develop', ['clean', 'browserify:standalone']);
|
||||
grunt.registerTask('filer-test', ['clean', 'browserify:testVersion']);
|
||||
grunt.registerTask('filer-test', ['clean', 'browserify:testVersion', 'browserify:testApp']);
|
||||
grunt.registerTask('release', ['develop', 'uglify']);
|
||||
grunt.registerTask('check', ['jshint']);
|
||||
|
||||
|
@ -210,7 +223,7 @@ module.exports = function(grunt) {
|
|||
'npm-publish'
|
||||
]);
|
||||
});
|
||||
grunt.registerTask('test-node', ['check', 'filer-test', 'connect:server_for_node', 'shell:mocha']);
|
||||
grunt.registerTask('test-node', ['check', 'clean', 'connect:server_for_node', 'shell:mocha']);
|
||||
grunt.registerTask('test-browser', ['check', 'filer-test', 'connect:server_for_browser']);
|
||||
grunt.registerTask('test', ['test-node']);
|
||||
|
||||
|
|
|
@ -6,26 +6,18 @@
|
|||
<script src="../bower_components/chai/chai.js"></script>
|
||||
<script src="../bower_components/mocha/mocha.js"></script>
|
||||
<script>
|
||||
// Polyfill for function.bind, which PhantomJS seems to need, see
|
||||
// https://gist.github.com/Daniel-Hug/5682738/raw/147ec7d72123fbef4d7471dcc88c2bc3d52de8d9/function-bind.js
|
||||
Function.prototype.bind = (function () {}).bind || function (b) {
|
||||
if (typeof this !== "function") {
|
||||
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
||||
}
|
||||
mocha.setup('bdd').timeout(5000).slow(250);;
|
||||
|
||||
function c() {}
|
||||
var a = [].slice,
|
||||
f = a.call(arguments, 1),
|
||||
e = this,
|
||||
d = function () {
|
||||
return e.apply(this instanceof c ? this : b || window, f.concat(a.call(arguments)));
|
||||
};
|
||||
c.prototype = this.prototype;
|
||||
d.prototype = new c();
|
||||
return d;
|
||||
// Intentional globals
|
||||
expect = chai.expect;
|
||||
assert = chai.assert;
|
||||
|
||||
window.onload = function() {
|
||||
mocha.checkLeaks();
|
||||
mocha.run();
|
||||
};
|
||||
</script>
|
||||
<script src="../lib/require.js" data-main="require-config"></script>
|
||||
<script src="test-bundle.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
// Tests to be run are defined in test-manifest.js
|
||||
|
||||
// For Nodejs context, expose chai's expect method
|
||||
if (typeof GLOBAL !== "undefined") {
|
||||
GLOBAL.expect = require('chai').expect;
|
||||
}
|
||||
|
||||
require('./test-manifest.js');
|
Loading…
Reference in New Issue