PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, October 9, 2022

[FIXED] What happens to unit tests and e2e tests in production Angular builds?

 October 09, 2022     angular, compilation, continuous-integration, javascript, typescript     No comments   

Issue

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?


Solution

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.



Answered By - The Fabio
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing