Reputation: 38418
I'm trying to get Karma to Jamine's ajax.js
https://github.com/IDCubed/karma-jasmine-ajax
My karma config has:
module.exports = function(config) {
config.set({
...
frameworks: ['jasmine-ajax', 'jasmine'],
});
};
My package.json has:
"devDependencies": {
"bower": "^1.4.1",
"del": "^1.1.1",
"gulp": "^3.8.11",
"gulp-concat": "^2.5.2",
"gulp-karma": "0.0.4",
"jasmine-ajax": "^3.1.0",
"jasmine-core": "^2.2.0",
"karma": "0.12.31",
"karma-chrome-launcher": "0.1.7",
"karma-cli": "0.0.4",
"karma-jasmine": "0.3.5",
"karma-jasmine-ajax": "^0.1.12",
"karma-junit-reporter": "^0.2.2",
"yargs": "^3.7.1"
}
and my spec is like so:
describe("mocking ajax", function() {
describe("suite wide usage", function() {
beforeEach(function() {
jasmine.Ajax.install();
});
afterEach(function() {
jasmine.Ajax.uninstall();
});
it('does something', function() {
});
});
});
But I have this error:
/node_modules/karma/node_modules/di/lib/injector.js:9
throw error('No provider for "' + name + '"!');
^
Error: No provider for "framework:jasmine-ajax"! (Resolving: framework:jasmine-ajax)
I'm obviously missing some plugin or something... but what?
Upvotes: 3
Views: 2789
Reputation: 1724
I am using Karma 3.0.0, and it returns this error if the frameworks are not configured as plugins like the following. I've created a pull request to update the documentation.
module.exports = function(config) {
config.set({
frameworks: ['jasmine-ajax', 'jasmine'],
plugins: ['karma-jasmine', 'karma-jasmine-ajax']
});
};
Upvotes: 0
Reputation: 4151
Just spent a good 4 hours dealing with the same issue. There are several things going wrong here, the core of it being: there are specific version conflicts and requirements for 'jasmine', 'jasmine-ajax', and 'karma-jasmine-ajax'.
I use Jasmine 1.3, and the current version of karma-jasmine-ajax
depends on a version of jasmine-ajax
that is incompatabile with Jasmine 1.3.x.
This is noted in the jasmine-ajax
documentation, but not the karma-jasmine-ajax
documentation: "This branch is now version 2.0, if you need jasmine-ajax for Jasmine 1.3.x please grab the last release from that tag."
In order to fix this specific conflict, I specified "karma-jasmine-ajax": "0.1.3",
in my package.json and removed my dependency on jasmine-ajax (which karma-jasmine-ajax will include itself).
Lastly, the documentation for jasmine-ajax is also incorrect for certain versions of jasmine-ajax: some use request.RespondWith
and others use request.response
. My specific version combination required request.response
.
Hope this helps.
Upvotes: 1