因果报应fs.readFileSync,我的代码未使用

时间:2018-09-11 21:29:10

标签: angularjs karma-jasmine karma-runner

我正在使用Karma和Jasmine测试我用Typescript编写的AngularJS代码。以下是我当前的Karma配置:

// Karma configuration
// Generated on Mon Nov 11 2013 10:04:08 GMT-0600 (Central Standard Time)
//Seperate karma config for Typescript due to module loading
var configApp = require('./gulp/gulp.config.js')();
var clientApp = require('./gulp/gulp.client.js')();
var commonApp = require('./gulp/gulp.common.js')();

module.exports = function (config) {
    config.set({

        // base path, that will be used to resolve files and exclude
        basePath: '',

        files: [
            'node_modules/angular/angular.js',
            'node_modules/angular-animate/angular-animate.js',
            'node_modules/angular-mocks/angular-mocks.js',
            'node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js',
            'node_modules/core-js/client/shim.min.js',
            'node_modules/d3/d3.js',
            'node_modules/jquery/dist/jquery.js',
            'node_modules/nvd3/build/nv.d3.js',

            './app_common/globalVariables.test.ts',

            './app_common/app.js',
            './app/app.js',

            './app_common/**/*.ts',
            './app/**/*.js',
            './app/**/*.ts'
        ],

        preprocessors: {
            './app_common/**/*.ts': ['karma-typescript'],
            './app/**/*.ts': ['karma-typescript']
        },

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,
        // logLevel: config.LOG_DEBUG,

        plugins: [
            'karma-chrome-launcher',
            'karma-jasmine',
            'karma-junit-reporter',
            'karma-typescript'
        ],

        // frameworks to use
        frameworks: [
            'jasmine',
            'karma-typescript'
        ],

        karmaTypescriptConfig: {
            include: {
                mode: "replace",
                values: [
                    "app_common/**/*.ts",
                    "app/**/*.ts"
                ]
            },
            tsconfig: "./tsconfig.json"
        },

        // test results reporter to use
        reporters: [
            'progress',
            'junit',
            'karma-typescript'
        ],

        coverageReporter: {
            reporters: [{
                type: 'text-summary'
            }]
        },

        junitReporter: {
            outputDir: 'KarmaTests/config',
            outputFile: 'junit.xml',
            suite: 'rft.config.js'
        },

        // web server port
        port: 9877,

        // enable / disable watching file and executing tests whenever any file changes
        browsers: ['ChromeHeadless'],

        // If browser does not capture in given timeout [ms], kill it
        captureTimeout: 60000,
        browserNoActivityTimeout: 30000
    });
};

运行测试时,出现以下错误:

{
    "message": "An error was thrown in afterAll\nUncaught TypeError: fs.readFileSync is not a function",
    "str": "An error was thrown in afterAll\nUncaught TypeError: fs.readFileSync is not a function"
}

但是,在我的appapp_common目录中搜索代码不会产生fs.readFileSync的使用,而且我可以肯定地从{{1}传入的库代码}都没有(不过,老实说,我没有明确检查过)。没有堆栈跟踪或其他任何内容,我很难确定此错误的来源。有没有人看过这个或知道如何显示堆栈跟踪?

0 个答案:

没有答案