lio*_*fox 6 testing jasmine typescript karma-runner angular
出于某种原因,我无法理解,Karma 说 Jasmine 找不到我的任何测试规范。我正在使用 Angular 9、Typescript 并ng test运行测试。我还跑去jasmine init创建 jasmine.json 配置文件。我尝试了几次配置更改,创建了一个虚拟测试 javascript 文件等等,但我仍然收到相同的“未找到规格”消息。这真的很令人沮丧,我敢肯定我只是在这里忽略了一些明显的东西。
测试文件夹结构:
spec
services
address.service.spec.ts
login.service.spec.ts
...
support
jasmine.json
Run Code Online (Sandbox Code Playgroud)
茉莉花.json:
{
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.js", // tried with "**/*[sS]pec.ts"
"services/*[sS]pec.js" // tried with "services/*[sS]pec.ts"
],
"helpers": [
"helpers/**/*.js" // tried with "helpers/**/*.ts"
],
"stopSpecOnExpectationFailure": false,
"random": false
}
Run Code Online (Sandbox Code Playgroud)
业力.conf.js :
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(
__dirname,
'./coverage/censored',
),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true,
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true,
});
};
Run Code Online (Sandbox Code Playgroud)
G-U*_*nit 18
我今天遇到了这个错误,对我来说,这是我的文件中有语法级错误.ts,所以它们无法真正编译。
在上述情况下,我认为测试不应该开始(而是显示编译错误)。
但无论出于何种原因,测试都会以某种方式开始,并Jasmine以“”日志失败No specs found。
| 归档时间: |
|
| 查看次数: |
13638 次 |
| 最近记录: |