Open mzellho opened 5 years ago
hi @mzellho thank you for raising! We will take a closer look at this. I think the model manager changed slightly and we need to update the app routing logic for this. I'd encourage you to look at: https://github.com/adobe/aem-spa-project-archetype for the latest testing strategies and the We.Retail Journal app for another example of app routing: https://github.com/adobe/aem-sample-we-retail-journal/blob/master/angular-app/src/app/app-routing.module.ts
I noticed some strange behaviour when accessing the Angular App via
ng serve
.Please note: all of this can easily be reproduced by checking out
angular/chapter-8
and runningng serve --proxy-config ./proxy.mock.conf.json
orng test
When accessing the application at http://localhost:4200, the application cannot initialize correctly and throws two (!) "ERROR Error: "Uncaught (in promise): Object: {"response":{}}"".
Since the URL in the browser got updated to http://localhost:4200/content/wknd-events/angular/home.html, F5'ing will correctly load the application. Resetting the URL to http://localhost:4200 unsurprisingly leads to the same error.
I tried to dig into this error, but couldn't find the reason. I highly suspect it has something to do with the initialization of ModelManager. I tried many ways of delaying the initialization until the URL of the browser got updated, but couldn't get it working.
Since in production we anyways would call a "complete" URL, this would work there, but I am having a really hard time writing tests as the tests would access http://localhost:9876 and no "complete" URL.
I am mainly using the mock-json-approach which is working fine for development purposes. Any ideas whether this approach could also work in combination with
ng test
and a proxy config inkarma.conf
?P.S.: Tests in this tutorial are failing as well - any chance we could get a chapter on testing?