Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stack trace is hidden when running Mocha from Grunt task

I need to see a stack trace when a test fails, but something is hiding it when Grunt runs the Mocha test suite. When I run the tests myself (mocha --recursive) I do get a stack trace:

site/server/server.js:10
    server.use( express.static( path.join( __dirname( '../client' ))));
                                           ^
TypeError: string is not a function
    at ...

But with this Gruntfile:

'use strict';

var should = require( 'should' );

module.exports = function( grunt ) {
    grunt.initConfig({
        cafemocha: {
            test: {
                src: 'server/test/**/test-*.js',
                options: {/*
                    ui: 'bdd',
                    growl: true,
                    coverage: true,
                    reporter: 'spec'
                */}
            }
        },

        watch: {
            files: [
                'server/**/*.js',
                'Gruntfile.js',
                'package.json'
            ],
            tasks: [ 'test' ]
        },

        complexity: {
            generic: {
                src: [
                    'server/**/*.js',
                    'Gruntfile.js'
                ],
                options: {
                    cyclomatic: 2,
                    halstead: 9,
                    maintainability: 80
                }
            }
        }
    });

    grunt.loadNpmTasks( 'grunt-notify' );
    grunt.loadNpmTasks( 'grunt-contrib-watch' );
    grunt.loadNpmTasks( 'grunt-cafe-mocha' );
    grunt.loadNpmTasks( 'grunt-complexity' );

    grunt.registerTask( 'default', [ 'cafemocha' ]);
    grunt.registerTask( 'test', [ 'cafemocha', 'complexity' ]);
};

All I get is a summary of an error:

$ grunt test
Running "cafemocha:test" (cafemocha) task
Warning: string is not a function Use --force to continue.

Aborted due to warnings.
like image 239
Dan Ross Avatar asked Aug 30 '13 05:08

Dan Ross


1 Answers

Stack traces are hidden by default in grunt. Run grunt with grunt --stack to show them.

like image 108
Sindre Sorhus Avatar answered Oct 03 '22 20:10

Sindre Sorhus