Sam*_*i-L 4 testing configuration json angular
在Angular 5及更早版本中,要在生成组件时停止生成spec文件,我们必须在.angular-cli.json文件中添加以下内容:
{
...
"defaults": {
"spec": {
"class": false,
"component": false,
"directive": false,
"module": false,
"pipe": false,
"service": false
}
}
}
Run Code Online (Sandbox Code Playgroud)
在Angular 6+中,在此链接之后,我们必须在新的angular.json文件中添加next ,在schematics部分下:
....
"schematics": {
"@schematics/angular:component": {
....
"properties": {
....
"spec": {
"type": "boolean",
"description": "Specifies if a spec file is generated.",
"default": false
}
}
}
},
Run Code Online (Sandbox Code Playgroud)
但是在生成新组件时,即使在IDE重启后,仍会创建新的spec文件,但缺少什么?
你可以在angular-cli.json中设置它
{
"defaults": {
"component": {
"spec": false
}
}
}
Run Code Online (Sandbox Code Playgroud)
这将禁用生成所有spec文件.如果要禁用特定组件,
ng g c component-name --spec false
Run Code Online (Sandbox Code Playgroud)
感谢G. Ross在此处提供的链接,尽管该解决方案与 Angular 6的官方文档不匹配,但它对我有用。
在“ angular.json ”文件中的原理图部分下添加了下一个:
....
"schematics": {
"@schematics/angular:component": {
....
"spec": false,
....
}
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2690 次 |
| 最近记录: |