Javascript Karma run with ng test未找到任何要运行的测试
所以我在Angular 10项目中有一个默认的和一个自定义的spec.ts文件,它们都没有被Karma检测到。有没有线索说明为什么会发生这种情况 我的Karma配置文件(实际上未更改): 我的控制台输出:Javascript Karma run with ng test未找到任何要运行的测试,javascript,angular,karma-jasmine,config,karma-runner,Javascript,Angular,Karma Jasmine,Config,Karma Runner,所以我在Angular 10项目中有一个默认的和一个自定义的spec.ts文件,它们都没有被Karma检测到。有没有线索说明为什么会发生这种情况 我的Karma配置文件(实际上未更改): 我的控制台输出: Chrome 88.0.4324.104 (Windows 10): Executed 0 of 0 SUCCESS (0.013 secs / 0 secs) TOTAL: 0 SUCCESS 在Karma UI中会显示: Incomplete: No specs found, , ran
Chrome 88.0.4324.104 (Windows 10): Executed 0 of 0 SUCCESS (0.013 secs / 0 secs)
TOTAL: 0 SUCCESS
在Karma UI中会显示:
Incomplete: No specs found, , randomized with seed 27463
Myng版本
输出:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 10.1.7
Node: 12.13.1
OS: win32 x64
Angular: 10.2.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.1002.0
@angular-devkit/build-angular 0.1002.0
@angular-devkit/core 10.2.0
@angular-devkit/schematics 10.1.7
@angular/cdk 10.2.5
@angular/cli 10.1.7
@angular/material 10.2.5
@angular/material-moment-adapter 10.2.5
@schematics/angular 10.1.7
@schematics/update 0.1001.7
rxjs 6.6.3
typescript 3.9.7
我正在运行Angular 10,正如您在上面看到的,键入脚本3.9.7,也如上面所示…应该有一个名为
test.ts
的文件,它的行如下所示:
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
这些是负责查找测试的线路。可能您的测试不在文件所在的位置。/但我再次尝试将autoWatch设置为false和true,突然它再次工作。。。奇怪…有同样的问题。Angular docs说在他们正在测试的组件/服务旁边添加spec.ts文件,这些文件并不总是在根目录中。。。所以我很困惑。。我遗漏了什么?>它与
test.ts
中的上下文有关,我认为它找不到您的测试文件,特别是当它们不在根目录中时。
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);