karma-runner / karma-runner/karma
Tests start executing before page is loaded
- Dominant language
- JavaScript
- Stars
- 12k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
I 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.
``` javascript
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](https://github.com/karma-runner/karma-jasmine/issues/77)
Contributor guide
Research direction
Start by locating the karma-jasmine adapter.js createStartFn function and read the discussion linked in the issue, especially issue 77. Verify the test-start timing relative to DOM readiness and add or update coverage if the repository provides a relevant adapter test; done means the affected tests no longer begin before the DOM is ready.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100