【问题标题】:Karma not running tests. Executed 0 of 0 ERRORKarma 没有运行测试。执行 0 of 0 错误
【发布时间】:2019-01-08 04:04:33
【问题描述】:

我正在尝试在 karma 中进行测试,但每次运行 Karma 时都会遇到相同的错误:

$ karma start karma.conf.js --single-run

31 07 2018 12:56:48.134:INFO [karma]:Karma v1.7.1 服务器开始于 http://0.0.0.0:9876/

2018 年 31 月 7 日 12:56:48.138:INFO [启动器]:以无限并发启动浏览器 Chrome

31 07 2018 12:56:48.144:INFO [启动器]:启动浏览器 Chrome

31 07 2018 12:56:49.890:INFO [Chrome 67.0.3396 (Windows 10.0.0)]:连接到套接字 2we1ypnXUlTXv5IRAAAA,ID 为 14298953

Chrome 67.0.3396 (Windows 10.0.0):Executed 0 of 0 ERROR (0.006 secs / 0 secs)

我的(大部分)自动生成的 karma.conf.js 位于测试上方一层:C:\Users\king\Desktop\_REPOS\inventivangular\src

// Karma configuration
// Generated on Tue Jul 31 2018 12:30:22 GMT-0400 (Eastern Daylight Time)

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

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: 'C:/Users/king/Desktop/_REPOS/inventivangular/src/',


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


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


    // list of files 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
  })
}

要测试的文件的文件路径: C:\Users\king\Desktop\_REPOS\inventivangular\src\app

【问题讨论】:

    标签: karma-jasmine karma-runner


    【解决方案1】:

    刚从C:\Users\king\Desktop\_REPOS\inventivangular 运行ng test 就结束了,它生成了自己的 karma.conf.js 并且一切正常。

    如果您使用自动生成的测试,您可能需要:

    import { HttpClientTestingModule } from '@angular/common/http/testing' 
    

    和

    imports: [HttpClientTestingModule] 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-24
      • 2019-06-17
      相关资源
      最近更新 更多