【问题标题】:Karma+Jasmine tests not running with Chrome, "Executed 0 of 0 ERROR"Karma+Jasmine 测试未与 Chrome 一起运行,“Executed 0 of 0 ERROR”
【发布时间】:2018-10-30 10:06:39
【问题描述】:

我正在尝试使用 jasminekarma 测试我的项目 angular 5,但它显示了这个错误:

myProject\Front\src\app> ng test
Your global Angular CLI version (7.0.3) is greater than your local
version (1.7.4). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
30 10 2018 09:42:25.435:WARN [karma]: No captured browser, open http://localhost:9876/
30 10 2018 09:42:38.011:INFO [karma]: Karma v0.13.9 server started at http://localhost:9876/
30 10 2018 09:42:38.016:INFO [launcher]: Starting browser Chrome
30 10 2018 09:42:41.074:INFO [Chrome 69.0.3497 (Windows 10 0.0.0)]: Connected on socket RiQkM_n-0oc-xuYAAAAA with id 49828596
Chrome 69.0.3497 (Windows 10 0.0.0) ERROR: 'DEPRECATION:', 'Setting specFilter directly on Env is deprecated, please use the specFilter option in `configure`'

Chrome 69.0.3497 (Windows 10 0.0.0): Executed 0 of 0 ERROR (0.003 secs / 0 secs)

这是我的 karma.conf.js

// Karma configuration
// Generated on Mon Oct 29 2018 16:09:43 GMT+0000 (Maroc)

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

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '',


        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['jasmine'],

        //plugin needed
        plugins: [
            require('karma-jasmine'),
            require('karma-chrome-launcher'),
            require('karma-jasmine-html-reporter'),
            require('karma-coverage-istanbul-reporter'),
        ],


        // list of files / patterns to load in the browser
        files: [
            'src/app/*.spec.ts',
        ],


        // list of files / patterns to exclude
        exclude: [
        ],


        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {

        },


        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress'],


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


        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['Chrome'],


        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: false,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity
    })
}

and this the interface in Google Chrome:

我只是个初学者???我不确定这些信息是否足够。我尝试了很多我发现的解决方案,但总是同样的问题。有人可以帮我吗?

【问题讨论】:

  • 你使用的是什么版本的 karma/karma-jasmine/karma-chrome-launcher?
  • @Acey 我将我的角度升级到 7

标签: unit-testing jasmine karma-jasmine karma-runner


【解决方案1】:

这是由于与较新版本的 Chrome(对我而言,版本 70 失败)和最新版本的 jasmine (3.3.0) 不兼容造成的。短期解决方法是将您的 jasmine-core 版本锁定为 3.2.0。

【讨论】:

  • 作为 Jasmine 和 Karma 的初学者,如果我想弄清楚是什么原因造成的,我会失去理智。非常感谢。
猜你喜欢
  • 1970-01-01
  • 2019-01-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-04
  • 2016-10-06
  • 2016-05-21
相关资源
最近更新 更多