gruntjs - 从Grunt任务运行Mocha时,堆栈跟踪被隐藏

标签 gruntjs mocha.js

当测试失败时,我需要查看堆栈跟踪,但是当Grunt运行Mocha测试套件时,某些东西会隐藏它。当我自己运行测试(mocha --recursive)时,我确实得到了堆栈跟踪:

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

但是有了这个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' ]);
};

我得到的只是一个错误摘要:
$ grunt test
Running "cafemocha:test" (cafemocha) task
Warning: string is not a function Use --force to continue.

Aborted due to warnings.

最佳答案

默认情况下,堆栈跟踪在grunt中是隐藏的。用grunt --stack运行grunt来显示它们。

关于gruntjs - 从Grunt任务运行Mocha时,堆栈跟踪被隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18525883/

相关文章:

javascript - Typescript 和 Uglify 任务

javascript - 在 Yeoman 应用程序中使用 Grunt Build 缩小后出现 Angular "Unknown Provider"错误

javascript - Grunt grunt-contrib- Jasmine

node.js - 如何在 describe() 的 before() block 中动态生成 Mocha 测试?

javascript - 如何使用 mocha 运行一些初始化代码

javascript - 我如何在 AngularJS 应用程序中使用 grunt-uncss?

javascript - Grunt uglify 0.5 不写源图吗?

mocha.js - 在 cypress 中每次测试后获取测试状态

node.js - 在 Mocha 测试中监听 stdout 时“此套接字已关闭”

mysql - 在压力下测试时,nodejs 运行时停止响应