出于某种原因,我无法理解,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: [ …Run Code Online (Sandbox Code Playgroud)