-
Notifications
You must be signed in to change notification settings - Fork 21
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
test runs fail randomly, unable to execute the karma-loaded function #9
Comments
I have the same error on first run. Tests run with no problems after second try package.json{
"devDependencies": {
"barcoder": "~1.1.1",
"grunt": "~0.4.4",
"jasmine-reporters": "1.0.1",
"karma": "~0.12.24",
"karma-chai-plugins": "^0.2.3",
"karma-chrome-launcher": "~0.1.5",
"karma-coverage": "^0.2.6",
"karma-cucumberjs": "krzysztof-jelski/karma-cucumberjs",
"karma-jasmine": "~0.1.5",
"karma-junit-reporter": "~0.2.2",
"karma-ng-html2js-preprocessor": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.4",
"protractor": "~0.21.0",
"request": "~2.34.0"
}
} cucumber.conf.jsmodule.exports = function (config) {
var cucumberConfig = {
basePath: '../../../',
exclude: [],
files: [
..some files...
],
ngHtml2JsPreprocessor: {
moduleName: 'karma.cached.htmls',
cacheIdFromPath: function (filepath) {
return filepath.replace("main/webapp/app/", "/app/");
}
},
preprocessors: {'**/*.html': ['ng-html2js']},
frameworks: ['cucumberjs', 'chai'],
browsers: [
'PhantomJS'
],
port: 9877,
urlRoot: '/_karma_/',
singleRun: true,
autoWatch: false
};
config.set(cucumberConfig);
}; |
Same error here, any progress? |
Found it, it was a HTML parsing - JS timeout race condition. Pull request: #14 In the meantime if you still have this issue you can use the repository where this bug is already fixed: |
I had to close my previous pull request, the race condition was not resolved. After a little more investigation I think the problem is caused by the mix of this adapter which uses requirejs and the Karma load which does not. Within Karma's context.html document the last script tag makes a call to window.karma.loaded(), however this adapter is loading asynchronously at the same time, it's pure chance if it's finished loading before Karma tries to call start(). My previously closed pull request contains the necessary fixes to integrate with the Karma framework, primarily do not monkey with karma.loaded and do not call start() from the adapter. The trick now is to make sure the adapter loads completely before karma attempts to call start(). I see now why s9tpepper was trying to override the loaded function and was calling start() from the adapter code, it was an attempt to work around this race condition. A solution could be to remove requirejs, I don't see the value in AMD here. Module management could be handled by commonjs and browserify/webpack. |
Yea I thought this was resolved and then it reared its ugly head again. Going to try a few things this week to resolve this once and for all. |
@s9tpepper Did you manage to research the problem? It seems to happen very regularly here. replace: with: This change in node_modules/karma/static/context.html and debug.html in the same dir. Ok so no retry count etc, but it will get you moving in the right direction. |
When running my tests, they fairly regularly fail with the following message:
TypeError: 'undefined' is not a function (evaluating 'window.__karma__.loaded()')
. Rerunning the tests solves the problem, but the instability is frustrating when developing locally and unacceptable when it randomly fails on the ci-server (travis-ci).Is it possible that I have configured something incorrectly?
I'm executing the tests with grunt and the project is available here, if that would help diagnose.
The text was updated successfully, but these errors were encountered: