(Feature Request) Ability to use AOT in unit testing
Bug Report or Feature Request (mark with an x)
- [ ] bug report -> please search issues before submitting
- [x] feature request
Versions.
Repro steps.
The log given by the failure.
Desired functionality.
At @angular/core/testing v4.2.0, .ngSummary.ts files are introduced to support to use AOT in unit testing ( https://github.com/angular/angular/blob/master/CHANGELOG.md#features-4 ). Do you have a milestone about this?
I think it's useful to run unit testing with something like ng test --aot .
Mention any other details that might be useful.
If we could run unit tests in AOT than we would have caught the latest bug which was published with 4.4.1 (https://github.com/angular/angular/issues/19219) already on our build server, not just in staging, so this would be super useful.
I read in multiple places, that AOT should become default for angular 5 - is this true? would that resolve this issue afterwards?
Now that Angular@5 is released, this should be have more priority since we now need the reflect-es7 polyfills just to be able to run the unit tests: AOT can be enabled for serve/build, but not unit tests which is against the "AOT by default" promoted with Angular@5.
Or maybe there is another way to enable AOT for tests (unit/e2e) or workaround for this, @hansl any ideas?
Sorry for asking a question here but this is a blocking issue for us.
Can anyone explain to me how to use relative template urls (aot style) in the source code, and then unit test that same source code with JIT.. i seem to be missing a trick?
or is there another trick to unit test with AOT?
thanks!
Any update on this issue?
There is a PR for it (https://github.com/angular/angular-cli/pull/8007), as as mentioned in https://github.com/angular/angular-cli/pull/8007#issuecomment-336973766 this support is still experimental and we'll wait until the feature stabilizes before incorporating it into the CLI.
Just a +1 for this. Hopefully the compiler folks determine that AoT support is stable soon. Not only would this catch AoT compile errors, but it should also vastly speed up test runs because all of the components won't need to be re-compiled over and over again for every single spec method.
This would be very useful. Since we are adopting AOT since 4.0, we ended up having another build step with AOT to ensure everything works
Really, nothing has happened since June 2017? AOT is meanwhile almost a must and tests don't adopt it?
@seawave23 Agree, and it's so sad that at a time where the focus is put on reducing the bundle size (Ivy renderer...) we still must keep the reflect-es7 polyfill just because of we cannot use AOT in unit tests 😕
@sinedied with Angular CLI v6 you could use a separate polyfills.ts for the Unit tests in JIT mode. That means you don't need the reflect-ts7 for the real build 🎉
@sinedied with Angular CLI v6 you could use a separate polyfills.ts for the Unit tests in JIT mode. That means you don't need the reflect-ts7 for the real build 🎉
That's good news for a start, but still I don't like the fact that the code going to production is not the same one being tested, with different polyfills and build methods.
That's good news for a start, but still I don't like the fact that the code going to production is not the same one being tested, with different polyfills and build methods.
Our development, QA and E2E testing is done using AOT mode - I can "live" with that danger/rsik that JIT it used for the unit tests for the time being, but totally agree that the AOT support is long overdue :)
@timbru31 How are you running your E2E tests in AOT mode? I am on ng6 and there is no --aot option.
Just as a note, the wiki states it is possible, or implies it anyways... https://github.com/angular/angular-cli/wiki/test
@boldwade I can't find anything on the wiki you linked that states that aot can be used.
It's ambiguous. The wiki page (listed above) links to the ng test page with supposed options that are available for said command. At the very least, it implies, at least to me, that I can run ng test with --prod options.
But does this mean that aot will/can be used?
right, see the confusion...
I suspect this would also make it possible to include template binding expressions in code coverage reports (as suggested here https://github.com/angular/angular/issues/427) which would be useful - currently I find the code coverage report pretty meaningless for components that include a lot of logic in their templates.
@filipesilva by what feature/bug is this blocked?