Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Support AOT compilation #2582

Open
waterplea opened this issue Jul 16, 2024 · 2 comments
Open

[Feature]: Support AOT compilation #2582

waterplea opened this issue Jul 16, 2024 · 2 comments

Comments

@waterplea
Copy link

🚀 Feature Proposal

It looks like currently JIT compiler is hardcoded:
https://github.com/thymikee/jest-preset-angular/blob/main/src/compiler/ng-jest-compiler.ts#L63

I would be nice if we could use Jest with Angular AOT.

Motivation

JIT is barely ever used for years and is a very obscure mode that can cause issues that do not occur in real apps. AOT has been the default for nearly 10 major versions. Using AOT in Jest would improve testing environment by bringing it closer to the real life.

Example

No response

@ahnpnl
Copy link
Collaborator

ahnpnl commented Jul 16, 2024

We are following Angular CLI regarding to unit test. With Angular CLI, it also uses JIT compilation.

In general, to support AOT, we need a different flow comparing to current way. It will be kind of like

  • Build the tests and app source codes in AOT mode
  • Trigger Jest to run on the output build folder

According to what I've known, using JIT compilation for test is faster than AOT.

@alan-agius4 would you please give us some more insights why Angular CLI uses JIT compilation for test? Thank you

@alan-agius4
Copy link

alan-agius4 commented Jul 16, 2024

AOT compilation speed has improved significantly over the years, so the speed improvements over JIT aren't that substantial. In the Angular CLI, JIT is currently used for unit tests but we are considering providing an option to use AOT. However, we first need to address a few questions, mainly concerning the correct semantics for writing tests and certain testing APIs that are JIT specific.

//cc @clydin and @dgp1130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants