-
Notifications
You must be signed in to change notification settings - Fork 12k
Absolute or Relative templateUrls for Angular Components aot #8633
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
Comments
I don't have any example for you to follow but the loader works in webpack, so if you're using webpack in karma then it should work too. However, you mention AOT a fair few times but there is not support for unit tests in AOT yet (see #8007 for info). We only replace template paths with require calls for JIT. So if you're trying to use AOT in unit tests I'd expect you to get those errors, because unit tests are not being ran with AOT and when a component is loaded, it will fail to load the template. If you can put up a repro using JIT where unit tests are not running correctly, I'm happy to take a look. |
Thank you so much! I think you can hopefully get me on the right track with 1 more question. I unfortunately was coming to the same conclusion that karma unit tests do not support AoT, but I'm still confused on the best practice here.. I had to change my source code to have relative urls everywhere for each component's style and template url. that's source code changes that were required to run the app with AoT (as far as I understood). so do I now need another set of source code with absolute paths to run the unit tests? as far as repro steps, I think you have foreseen my problem. i am trying to unit test with relative (aot) urls in the source code. but what's the trick here without 2 urls in the source code? (absolute urls for jit unit tests and relative urls for aot production) |
i needed angular2-template-loader to pull this off |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
angular/cli: 1.5.3
angular-devkit/build-optimizer: 0.0.33
angular-devkit/core: 0.0.20
angular-devkit/schematics: 0.0.36
ngtools/json-schema: 1.1.0
ngtools/webpack: 1.8.3
schematics/angular: 0.1.5
typescript: 2.6.1
webpack-bundle-analyzer: 2.9.1
webpack-merge: 4.1.1
webpack: 3.8.1
WINDOWS 10
I've been stuck trying to get AOT working with my Webpack Unit Tests. (ngtools/webpack).
OR at least along-side my unit tests....
Can anyone help me at all? Or have any examples?
The main issue I'm seeing seems to be with the component's templates. The component tests all say 'Failed to load xxx.html'. During the karma unit tests..
I am trying to unit test with relative (aot) urls in the source code. but what's the trick here without 2 urls in the source code? (absolute urls for jit unit tests and relative urls for aot production)??
What am I missing?
I am using webpack with aot NOT angular-cli for a use project and this is a blocker..
The text was updated successfully, but these errors were encountered: