簡體   English   中英

Grunt Karma運行測試但受阻

[英]Grunt Karma runs tests but blocks

我有一個艱巨的任務要使用Phantom JS運行Karma單元測試。 測試已運行,但任務沒有退出。 這會阻止其他任務啟動,直到我使用ctrl + c手動殺死karma:unit任務為止。

我的karma.conf.js文件是:

// Karma configuration
// Generated on Thu Mar 06 2014 13:17:21 GMT-0500 (Eastern Standard Time)

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

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


    // frameworks to use
    frameworks: ['mocha', 'requirejs', 'chai', 'sinon'],


    // list of files / patterns to load in the browser
    files: [
      { pattern: 'src/vendor/**/*.js', included: false },
      { pattern: 'src/*.js', included: false },
      { pattern: 'src/app/*_test.js', included: false },
      { pattern: 'src/app/**/*.js', included: false },
      { pattern: 'src/app/*_test.js', included: false },
      'test-main.js'
    ],


    // list of files to exclude
    exclude: [
      'src/app/main.js',
      '**/Gruntfile.js'
    ],


    // test results reporter to use
    // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
    reporters: ['progress', 'coverage'],
    preprocessors: {
      'src/app/**/!(*_test).js': 'coverage'
    },


    // web server port
    port: 9876,


    // 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,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,


    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera (has to be installed with `npm install karma-opera-launcher`)
    // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
    // - PhantomJS
    // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
    browsers: ['PhantomJS'],


    // If browser does not capture in given timeout [ms], kill it
    captureTimeout: 10000,


    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: true
  });
};

我的業力任務的Grunt配置是:

karma: {
            options: {
                configFile: 'karma.conf.js'
            },
            unit: {
              autowatch: true,
              singleRun: true,
            }
        },

當我運行grunt karma:unit時,我得到:

Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.0 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Windows 7)]: Connected on socket V2NFfUtyUi_gl0gWqbov with id 17494532
PhantomJS 1.9.7 (Windows 7): Executed 2 of 2 SUCCESS (0.012 secs / 0 secs)

但是直到我按ctrl + C時它才Done, without errors

我在項目中重新安裝了業力和PhantomJS,問題已解決。 我注意到,當我更改業力配置以使用Chrome時,一切正常,因此我認為問題一定出在PhantomJS上。

npm install karma --save-dev

npm install phantomjs --save-dev

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM