karma-jasmine - Karma 没有运行测试。执行 0 of 0 错误
问题描述
我正在尝试在 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 年 3 月 7 日 12:56:48.138:INFO [启动器]:以无限并发启动浏览器 Chrome
2018 年 7 月 31 日 12:56:48.144:INFO [启动器]:启动浏览器 Chrome
2018 年 7 月 31 日 12:56:49.890:INFO [Chrome 67.0.3396 (Windows 10.0.0)]: 连接到套接字 2we1ypnXUlTXv5IRAAAA,ID 为 14298953
Chrome 67.0.3396(Windows 10.0.0):执行 0 of 0 错误(0.006 秒/0 秒)
我的(大部分)自动生成的 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
解决方案
刚运行就结束了ng test
,C:\Users\king\Desktop\_REPOS\inventivangular
它生成了自己的 karma.conf.js 并且一切正常。
如果您使用自动生成的测试,您可能需要:
import { HttpClientTestingModule } from '@angular/common/http/testing'
和
imports: [HttpClientTestingModule]
推荐阅读
- javascript - 如果用户不响应,Alexa 会发出错误(“技能响应被标记为失败”)
- c# - MethodInfo.Invoke 返回的对象与目标类型不匹配
- python - 如何在表示航班的字典中列出重复值?
- python - python numpy exponentially spaced samples between a start and end value
- c++ - 我应该如何运行游戏循环并更改其对象?
- javascript - 带有 javascript 的交互式日历
- javascript - 如何在另一个文件中获取组件的状态反应本机
- python - Groupby 前两个最早日期,然后是前两个日期之间的平均时间 - 熊猫
- php - 图像生成
- android - 使用 Kotlin 检索 Firebase 数据并为列表视图填充模型