在 Azure 管道中构建 Angular 项目之前运行单元测试。

huangapple go评论92阅读模式
英文:

Running unit tests before building the Angular project in an Azure Pipeline

问题

为什么在 Azure 管道中构建 Angular 项目之前运行单元测试通常是一种推荐的做法?还有可能假设运行测试必须包括构建。我已经在很多地方看到人们首先添加一个运行单元测试的步骤,然后是构建项目的步骤,如下所示:

在 Azure 管道中构建 Angular 项目之前运行单元测试。

英文:

Why running unit tests before building the Angular project in an Azure Pipeline is generally a recommended practice?
Also presumably running the tests must include a build.

I have seen at many places people add a step to Run Unit Test first and followed by the Build project step like below

在 Azure 管道中构建 Angular 项目之前运行单元测试。

答案1

得分: 1

这里有几个原因:

  • 构建前端应用与构建编译代码不同,这意味着你不一定要为整个应用构建。
  • 当你构建前端应用时,大多数情况下会将测试排除在最终包之外(没有理由部署它们,对吧)。
  • 此外,你还需要添加一些额外的步骤来构建你的应用,比如代码最小化。想象一下,实际上读取这些经过最小化的测试会有多复杂(有一个例外,通常在内部环境中,代码未经最小化)。
  • 要执行你的测试,你不必构建你的代码,而是测试运行器只会将代码转译成JavaScript(如果你使用TypeScript)。
英文:

There are few reasons here:

  • building front end app is not the same as building compile code, it means that not necessarily you have to build your for whole app
  • when you build front end app you in most case exclude tests from final package (there is no reason to have them deployed, right)
  • additionally you also add some additional steps for building your app like minimising code. Imagine how complex it would be actually do read such tests which are minimised (with one exclusion here, quite often for internal environments code is not minimised)
  • to execute your test you don't have to build your code, but test runners just transpile code to JavaScript (if you use typescript).

huangapple
  • 本文由 发表于 2023年8月4日 20:41:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76836013.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定