生产角构建中的单元测试和E2E测试会发生什么?

发布于 2025-02-07 23:12:47 字数 208 浏览 1 评论 0原文

假设我正在运行默认生产angular.json中构建设置。当我运行npm build -prod时,我的所有单元测试和E2E测试文件(量角或柏树)会发生什么?这些文件是在dist文件夹中的最终构建中包含的,还是将它们排除在于降低捆绑包的大小?在生产中的包含或排除测试文件是否可以配置?

Let's say I'm running default production build settings in angular.json. What happens to all of my unit test and e2e test files (Protractor OR Cypress) when I run npm build --prod? Are these files included in the final build within the dist folder, or are they excluded to reduce bundle size? Is this inclusion or exclusion of test files in production builds configurable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分開簡單 2025-02-14 23:12:47

Angular具有其 prod构建过程称为“摇摇欲坠”和“ dead-code nighation”的过程。 Angular Prod应用程序和/或其依赖项未使用的任何代码将从构建代码中删除。

此答案提供了有关它如何用于Angular builds

tl; dr; dr;

如果您的对象/功能/类(是否测试)由您的组件/模块/服务/(以及其他Angular Blocks或其他JS/TS代码依赖项)引用,则几乎可以肯定会保留在构建的应用中。所有其他代码将从构建的应用程序中删除。

如果您希望从测试文件中保留一些代码保留在构建文件中,则需要从JS文件中引用该文件的导出对象/函数,并以某种方式使用该引用。

Angular has in its prod build process procedures called "tree-shaking" and, "dead-code elimination". Any code that is not in use by the angular prod app and/or its dependencies is removed from the built code.

This answer provides good details on how it works for angular builds

tl;dr;

If your object/function/class (test or not) is referenced by your components/modules/services/(and other angular blocks or other js/ts code dependencies) it is almost certain to remain into the built app. All other code is removed from the built app.

if you want some code from test files to remain in the built files, you will need to reference that file's exported objects/function from your js files and use that reference somehow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文