From a4c08746686cb123066f42bd47757c0668210963 Mon Sep 17 00:00:00 2001 From: Kieran Sedgwick Date: Mon, 26 May 2014 16:29:46 -0400 Subject: [PATCH] Browserify test suite Our tests run in the browser and on node! Switching to browserify made this necessary. --- gruntfile.js | 23 ++++++++++++++++++----- tests/index.html | 26 +++++++++----------------- tests/index.js | 8 ++++++++ 3 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 tests/index.js diff --git a/gruntfile.js b/gruntfile.js index 6a7fc93..837dc84 100644 --- a/gruntfile.js +++ b/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']); diff --git a/tests/index.html b/tests/index.html index 5a8e535..66f9800 100644 --- a/tests/index.html +++ b/tests/index.html @@ -6,26 +6,18 @@ - +
diff --git a/tests/index.js b/tests/index.js new file mode 100644 index 0000000..ad8150c --- /dev/null +++ b/tests/index.js @@ -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');