Tests start executing before page is loaded
See original GitHub issueI am using karma-jasmine: 0.3.5. I have tests that run perfectly from a HTML runner that loads jasmine 2.2 but when I run them through karma using karma-jasmine they fail. I have investigated the problem and it seems that the tests start executing before the DOM is ready (which is not the case when run from a HTML runner). After updating the createStartFn function in the adapter.js file to the code below which waits for the DOM ready the tests started passsing.
function createStartFn(karma, jasmineEnv) {
// This function will be assigned to `window.__karma__.start`:
return function () {
$(function () {
jasmineEnv = jasmineEnv || window.jasmine.getEnv();
jasmineEnv.addReporter(new KarmaReporter(karma, jasmineEnv));
jasmineEnv.execute();
});
};
}
Look at the discussion about the issue here
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
How to Wait until page is fully loaded - Stack Overflow
I've been using excessively long wait periods but would like the test to run faster. let targeturl = 'http:\\something.com' let longwait = 2500 ......
Read more >Load Testing Best Practices | LoadNinja
After running your load tests, the first obvious step is to identify any problem areas & take the next best steps to improving...
Read more >Catalog of Events - Cypress Documentation
Fires as the page begins to load, but before any of your applications JavaScript has executed. This fires at the exact same time...
Read more >unittest — Unit testing framework — Python 3.11.1 ...
The setUp() and tearDown() methods allow you to define instructions that will be executed before and after each test method. They are covered...
Read more >Detect if a Document Has Loaded with JavaScript
I thought the best way to avoid these problems was to ensure the document had loaded before each test run -- that way...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Guys should we wait event
DOMContentLoaded
orload
before starting tests?\cc @karma-runner/contributors
Have you tried to add something like