-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: karma.loaded() started too early (#2955) #2960
Conversation
On module, you need to wait explicitely on modules being loaded before starting the tests. This commit: - wait for modules to be loaded - add a test for modules
This is the same merge request as #2956, but where cla/google could pass.
|
The third point is ok (see conversation here #2956 (review)) |
@dignifiedquire The difference is:
From my point of view, the two commits changes a bit the karma behavior... Which one of the two is better for you? |
@jehon I think there might be a much simpler fix to this that would be backwards-compatible. I'm not sure if it is in the spec, but if you replace in <script type="text/javascript">
window.__karma__.loaded();
</script> with <script type="module">
window.__karma__.loaded();
</script> then everything seems to load correctly. The problem without |
Actually, looks like my suggestion is nearly exactly what is happening here: https://github.com/karma-runner/karma/pull/2834/files @jehon, What is the difference between your pull request and #2834 ? Seems like they are accomplishing the same task, though #2834 seems the more standards-compliant way to accomplish it if module loading of script tags changes based on the scripts importing modules or not |
When I started this, I didn't knew some works was done there. PS: And you also need a <script nomodule> for it to works on older browsers too. At my understanding, I am not sure that the "module" scripts are loading in order. I didn't see any garantee that the "inline" script would run after all the loaded modules. I think that if you have a module loading slowly, it could run after the "__karma__" stuff. But I am not sure about this. But I am sure that the DomContentReady should fire when all modules are loaded, and that this is compatible with all supported browsers. |
#2834 Has the |
Reading the W3C specs, I find that:
PS: module scripts are always async "As soon as it is available" is a bit confusing. But to my point of view, it does not implies that the scripts will run in order. |
Ah, I see. I'm not looking at the spec, but from reading some documentation I think type module makes the script For example, you can still put the async attribute on a type module script |
Deferred scripts maintain their order with other deferred scripts, and so if you have multiple type module scripts defined, they will all load in the order written in the html |
If what I've said is true, #2834 should work by maintaining the order of the scripts, since they are of type module meaning they are deffered |
Ah, ok. So the other solution seem more compatible... |
|
On module, you need to wait explicitely on modules being loaded before
starting the tests.
This commit:
This is the same as #2956, but with Google CLA ok