简体   繁体   English

Angular - 我应该在测试前还是测试后运行生产构建

[英]Angular - should I run production build before test or after test

If I am building a Java app for production, I'd have the build setup to build the production artefacts and then run the tests against those artefacts.如果我正在构建用于生产的 Java 应用程序,我会进行构建设置来构建生产工件,然后针对这些工件运行测试。

I've just joined an Angular project and noticed that the build is setup something like this:我刚刚加入了一个 Angular 项目,并注意到构建的设置如下:

ng test && ng lint && ng build --prod

..so its running test and lint before the actual build. ..所以它在实际构建之前运行测试和 lint。 Is the reason one might choose to do this an attempt to fail faster because the test build is quicker?人们可能选择这样做的原因是因为测试构建更快而尝试失败得更快吗? Is this standard practice in Angular apps?这是 Angular 应用程序中的标准做法吗?

The Angular tests run against the source files, the build produces a set of minified js files for deployment. Angular 测试针对源文件运行,构建生成一组缩小的 js 文件用于部署。 They are independent processes.它们是独立的进程。

The series of commands you have is effectively saying:您拥有的一系列命令实际上是在说:

if (source files passes tests && source files pass linting rules) {
  produce files for deployment
}

An Angular build isn't a particularly speedy process, so it's definitely better to fail fast if tests or linting fails. Angular 构建并不是一个特别快的过程,因此如果测试或 linting 失败,最好快速失败。 You're not running tests against outdated files - if that's the thrust of your question.您没有针对过时的文件运行测试 - 如果这是您问题的重点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Angular 中通过测试后运行 ng test 然后运行 ​​ng build - How do I run ng test and then ng build after tests pass in Angular 如何使用 Cloud Build 运行 angular 测试? - How to run angular test using Cloud Build? 量角器 - 在每次测试之前和每次测试之后运行代码 - Protractor - Run code before each test and after each test 我应该如何测试这个角度分量? - How should I test this angular component? 我必须在 Angular 生产版本之前修复所有 TS 错误吗? - Must I fix all TS errors before Angular production build? 当ng测试失败时,如何在ng build --prod和jenkins作业失败之前运行ng test? - How to run ng test before ng build --prod and fail jenkins job when ng test fails? 如何使用 `npm run build: production` 而不是使用`npm run build --production` 构建我的 angular 应用程序? - How do i build my angular application with `npm run build : production` instead of using `npm run build --production`? 在生产构建之前,您如何运行/调试/提供 Angular 元素? - How do you run/debug/serve an Angular Element before a production build? Angular - 发布前的测试库 - Angular - Test library before publish 角度| 使用生产环境变量启动测试服务器 - Angular | Start Test Server with Production Environment Variables
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM