Karma + Jasmine测试未与Chrome一起运行,“已执行0,共0个错误”

时间:2018-10-30 10:06:39

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

我正在尝试使用茉莉花业力测试我的项目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:

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

2 个答案:

答案 0 :(得分:2)

这是由于与较新版本的Chrome(对我而言,版本70失败)和最新版本的茉莉(3.3.0)不兼容而导致的。短期解决方法是将您的茉莉花核心版本锁定为3.2.0。

答案 1 :(得分:-2)

为纠正错误,我创建了一个新项目,并将一些文件移至当前项目:

  • karma.conf.js
  • tsconfig.json
  • tslint.json

以及已执行的npm ing t,并且测试运行正常。

相关问题