From 6bc36ed59cf863a3dd0ca28f1b1c04de23de1e94 Mon Sep 17 00:00:00 2001 From: Miguel Coba Date: Tue, 26 Aug 2014 04:53:07 +0000 Subject: [PATCH] Adds support for re-running server and client tests automatically Adds two more tasks to execute server and client tests separately To run full suite grunt test To run only server tests grunt test:server To run only client tests grunt test:client Fixes https://github.com/meanjs/mean/issues/155 --- README.md | 21 +++++++++++++++++++++ gruntfile.js | 12 +++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5fff8790..4b1a5acc 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,27 @@ Your application should run on port 3000, so in your browser just go to [http:// That's it! Your application should be running. To proceed with your development, check the other sections in this documentation. If you encounter any problems, try the Troubleshooting section. +## Testing Your Application +You can run the full test suite included with MEAN.JS with the test task: + +``` +$ grunt test +``` + +This will run both the server-side tests (located in the app/tests/ directory) and the client-side tests (located in the public/modules/*/tests/). + +To execute only the server tests, run the test:server task: + +``` +$ grunt test:server +``` + +And to run only the client tests, run the test:client task: + +``` +$ grunt test:client +``` + ## Development and deployment With Docker * Install [Docker](http://www.docker.com/) diff --git a/gruntfile.js b/gruntfile.js index fd0b02a2..b45a9cd7 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -4,7 +4,7 @@ module.exports = function(grunt) { // Unified Watch Object var watchFiles = { serverViews: ['app/views/**/*.*'], - serverJS: ['gruntfile.js', 'server.js', 'config/**/*.js', 'app/**/*.js'], + serverJS: ['gruntfile.js', 'server.js', 'config/**/*.js', 'app/**/*.js', '!app/tests/'], clientViews: ['public/modules/**/views/**/*.html'], clientJS: ['public/js/*.js', 'public/modules/**/*.js'], clientCSS: ['public/modules/**/*.css'], @@ -47,6 +47,10 @@ module.exports = function(grunt) { options: { livereload: true } + }, + mochaTests: { + files: watchFiles.mochaTests, + tasks: ['test:server'], } }, jshint: { @@ -173,5 +177,7 @@ module.exports = function(grunt) { grunt.registerTask('build', ['lint', 'loadConfig', 'ngAnnotate', 'uglify', 'cssmin']); // Test task. - grunt.registerTask('test', ['env:test', 'mochaTest', 'karma:unit']); -}; \ No newline at end of file + grunt.registerTask('test', ['test:server', 'test:client']); + grunt.registerTask('test:server', ['env:test', 'mochaTest']); + grunt.registerTask('test:client', ['env:test', 'karma:unit']); +};