angular-cli - Angular 11 CLI,“ng generate”选项:--skip-tests
问题描述
在使用 Angular 11 CLI 时,当我生成一个新组件时,我可以指定选项--skip-tests
以避免.component.spec.ts
在此阶段生成一个。
ng generate component --name asdf --module app --skip-tests --dry-run
当我生成一个包含新组件(--route
选项)的新模块时,我无法指定该--skip-tests
选项。
ng generate module --name asdf --module app --route asdf --routing true --skip-tests --dry-run
如果我这样做,我会收到错误:
Unknown option: '--skip-tests'
在这种情况下是否有另一种方法可以跳过生成测试,或者它只是不支持generate module
?
解决方案
根据这篇文章,您可以--skip-tests
在生成整个项目时添加标志,也可以生成单个组件。从逻辑的角度来看,您不能在模块上应用标志是有道理的,因为模块不是使用测试文件生成的。
要对所有未来生成的代码进行更改,请angular.json
通过添加skipTests:true
到原理图部分来修改您的文件。
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"skipTests": true
},
"@schematics/angular:class": {
"skipTests": true
},
"@schematics/angular:directive": {
"skipTests": true
},
"@schematics/angular:guard": {
"skipTests": true
},
"@schematics/angular:module": {
"skipTests": true
},
"@schematics/angular:pipe": {
"skipTests": true
},
"@schematics/angular:service": {
"skipTests": true
}
}
推荐阅读
- r - R Studio 折叠不保存
- python - m4 皮质处理速度与桌面处理器的粗略估计
- putty - MSP430,无法使用 UART no Output with Putty
- elasticsearch - CQRS 为什么不只为读写提供弹性搜索?
- matrix - 如何在区域的扩展区域内找到一个点?
- php - 无法将 MySQL 连接到 XAMPP
- laravel - Laravel Echo 存在通道与 vue 路由器无法正常工作
- javascript - `message` 字段值未在 NodeJS 中的 `CustomError` 类中设置,通过函数构造函数进行经典继承
- mysql - 在 MySQL 中创建关系
- sql - 计算每个月的成本 SQL