完全从angular4删除测试 [英] Completely removing tests from angular4
问题描述
我已经使用angular4构建了一个非常小的应用程序.我有主要的应用程序组件,两个子组件和一项服务.我觉得我不需要这么小的应用程序的测试,而是想要删除所有与使项目更清洁有关的测试
I have built a really small application using angular4. I have the main app component, two subcomponents and one service. I feel like I dont need tests for such a small application and want to remove everything test related to make the project cleaner
所以我的问题是我可以从项目中删除的所有与测试相关的文件是什么?我已经删除了组件下的规范文件,但是接下来该怎么办?我可以删除src/test.ts,src/tsconfig.spec.js,protractor.conf.js,karm.conf.js等吗?如果确实要删除某些配置,我是否需要修改某些配置?
So my question is what are all the files I can remove from my project that are related to testing? I already deleted the spec files under my components but what next? Can i delete the src/test.ts, src/tsconfig.spec.js, protractor.conf.js, karma.conf.js, etc? Do i have to modify some configurations if i do delete this?
还要注意的是,角度cli是否可以在没有所有与测试相关的内容的情况下创建新项目?
Also on a side note does angular cli allow to create a new project without all this test related stuff?
推荐答案
要构建没有规格文件的新项目,请执行以下操作:
To build a new project without spec files:
ng new --skip-tests true projectname
然后您可以删除:
- /e2e
- test.ts
- protractor.conf.js
- karma.conf.js
如果您不想掉毛,则:
- tslint.json
您还可以将package.json缩减为:
You can also reduce your package.json down to:
{
"name": "projectname",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build"
},
"private": true,
"dependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.0.4",
"@angular/compiler-cli": "^4.0.0",
"@types/node": "~6.0.60",
"ts-node": "~2.0.0",
"typescript": "~2.2.0"
}
}
在生成新的组件和服务时,可以在其后附加--spec false
以跳过测试文件的生成.
When generating new components and services you can append it with --spec false
to skip test file generation.
这篇关于完全从angular4删除测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!