-
Notifications
You must be signed in to change notification settings - Fork 12k
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
feat: add aot option to karma #28854
base: main
Are you sure you want to change the base?
Conversation
}) | ||
class Hello {} | ||
|
||
expect((Hello as any).ɵcmp.template.toString()).not.toContain('jit'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fragile and sensitive to any structural changes in JIT. It could easily cause false negatives.
What would be a better way to achieve this detection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think as long as we have a second test case that tests the reverse, it's fine..? That way we can make sure that "jit" appears in one branch and doesn't appear in the other, with aot: true
vs aot: false
as the only difference. That seems like an okay state to be in for now.
...BASE_OPTIONS, | ||
aot: true, | ||
/** Cf. {@link ../builder-mode_spec.ts} */ | ||
polyfills: ['zone.js', '@angular/localize/init', 'zone.js/testing'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we factorize this in BASE_OPTIONS
? or create a BASE_POLYFILLS
? or an object mother: optionsMother.base().withPolyfills()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describeKarmaBuilder
already runs the builder in both modes automatically. You shouldn't need any override but aot: true
in here if everything works as expected. The builder mode spec is special because it explicitly tests that the mode can be changed by explicitly setting this. But it seems wasteful to rerun this test case twice in application builder mode (which I think is what's currently happening with this file).
38ac095
to
48d0a96
Compare
Sorry for the lack of review so far but I just want to quickly say that I'm really excited to see this option added. |
No rush at all! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - sorry for the late review!
...BASE_OPTIONS, | ||
aot: true, | ||
/** Cf. {@link ../builder-mode_spec.ts} */ | ||
polyfills: ['zone.js', '@angular/localize/init', 'zone.js/testing'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describeKarmaBuilder
already runs the builder in both modes automatically. You shouldn't need any override but aot: true
in here if everything works as expected. The builder mode spec is special because it explicitly tests that the mode can be changed by explicitly setting this. But it seems wasteful to rerun this test case twice in application builder mode (which I think is what's currently happening with this file).
import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeKarmaBuilder } from '../setup'; | ||
import { BuilderMode } from '../../schema'; | ||
|
||
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to restrict this to application builder mode only, you might need to add the 3rd argument for this callback (isApplicationBuilder
) and skip/disable the test if that boolean is false.
}) | ||
class Hello {} | ||
|
||
expect((Hello as any).ɵcmp.template.toString()).not.toContain('jit'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think as long as we have a second test case that tests the reverse, it's fine..? That way we can make sure that "jit" appears in one branch and doesn't appear in the other, with aot: true
vs aot: false
as the only difference. That seems like an okay state to be in for now.
Thx! No problem at all. |
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Tests run in JIT only.
What is the new behavior?
Tests can run in AOT, using the new
aot
option.Does this PR introduce a breaking change?
Other information