sun*_*han 6 angular-universal angular angular-unit-test angular-test
在运行“ng test”命令时将 angular 7 项目转换为 angular Universal,错误为“ Incomplete: No specs found, , randomized with seed 48751”。尝试了不同的方式提及 stackoverflow,但对我来说没有任何作用。
ERROR in ./src/polyfills.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: ../src/polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (../node_modules/@ngtools/webpack/src/packages/ngtools/webpack/src/angular_compiler_plugin.ts:1024:15)
at plugin.done.then (../node_modules/@ngtools/webpack/src/packages/ngtools/webpack/src/loader.ts:49:29)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ multi ./src/polyfills.ts ./node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/jit-polyfills.js polyfills[0]
Run Code Online (Sandbox Code Playgroud)
预期输出为 ng test 命令正常运行而不会出现任何问题,以便我的单元测试用例执行。
如果某些单元测试文件中存在编译错误,则可能会发生此错误,如果发生这种情况,则在运行“ng test”的命令提示符中会看到编译错误。
例如,内置的“app.component.spec.ts”包含一个期望 title 变量具有 App 标题的测试。如果您已从“app.component.ts”中删除了此变量,则测试仍然包含该变量这一事实不会导致构建失败,但在运行测试时会出现错误。
最后经过大量实验得到了解决方案。只需添加
`"include": [
"**/*.spec.ts",
"**/*.d.ts",
"**/*.ts"
]`
Run Code Online (Sandbox Code Playgroud)
在“tsconfig.spec.json”中希望这有帮助:)
| 归档时间: |
|
| 查看次数: |
9146 次 |
| 最近记录: |