Is there a way to wait until all System.registers (transpiled from ES6) are resolved and loaded?
This is especially useful for e2e testing in Angular and other little things.
Is there a way to wait until all System.registers (transpiled from ES6) are resolved and loaded?
This is especially useful for e2e testing in Angular and other little things.
System.import the module you want to wait for which returns a promise.
System.import("myModule").then(function() {
// here it is loaded.
});
In practice, you probably want to use something like systemjs-builder with route specific bundling logic rather than load things with system on the first page load - so less round trips are made to the server.
The Problem with System.import().then is that the second-level dependencies will not get resolved.
System.register has a "callback" that is executed when all its dependencies (and dependencies of its dependencies, etc. ) are resolved.
When transpiling from ES6, basically this "callback" constructed from the rest of the code in the fileāall the code expect the import statements. Therefore, I don't really have to do anything with SystemJS to get a callback to start the tests; the problem is now how to get testing, i.e. Protractor, to start manually. Currently, the workaround is to delay the testing by a fixed ~30 seconds.