There is no provider for "framework: requirejs"! (Resolution: framework: requirejs)

I downloaded this jasmine karma code example , I searched a lot and it seems to work.

But when I run

karma start karma.conf.js 

he gives me this error:

  /Users/xe4me/www/html/apache/requirejs- karma/node_modules/karma/node_modules/di/lib/injector.js:9 throw error('No provider for "' + name + '"!'); ^ Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine) at error (/Users/xe4me/www/html/apache/requirejs-karma/node_modules/karma/node_modules/di/lib/injector.js:22:68) at Object.parent.get (/Users/xe4me/www/html/apache/requirejs-karma/node_modules/karma/node_modules/di/lib/injector.js:9:13) at get (/Users/xe4me/www/html/apache/requirejs-karma/node_modules/karma/node_modules/di/lib/injector.js:54:19) at /Users/xe4me/www/html/apache/requirejs-karma/node_modules/karma/lib/server.js:29:14 at Array.forEach (native) at start (/Users/xe4me/www/html/apache/requirejs-karma/node_modules/karma/lib/server.js:28:21) at invoke (/Users/xe4me/www/html/apache/requirejs-karma/node_modules/karma/node_modules/di/lib/injector.js:75:15) at Object.exports.start (/Users/xe4me/www/html/apache/requirejs-karma/node_modules/karma/lib/server.js:307:12) at Object.exports.run (/Users/xe4me/www/html/apache/requirejs-karma/node_modules/karma/lib/cli.js:220:27) at requireCliAndRun (/usr/local/lib/node_modules/karma-cli/bin/karma:44:16) 

I also made the method below, with no luck:

  npm install karma-requirejs --save-dev 

I did everything right, but still no luck, and there are also some questions in SO that seem the same as mine, I tried all the answers, but still no luck;

any help would be appreciated

thanks

+5
source share
1 answer

You need requirejs and karma-requirejs :

 npm install requirejs --save-dev npm install karma-requirejs --save-dev 

After that, be sure to configure Karma as described in " " Run Karma with Require.js ".

Minimal working example (generated by karma init )

karma.conf.js

 module.exports = function(config) { config.set({ basePath: '', frameworks: ['jasmine', 'requirejs'], files: [ {pattern: 'dest/main/**/*.js', included: false}, {pattern: 'test/**/*Spec.js', included: false}, 'test-main.js' ], exclude: [], preprocessors: {}, reporters: ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: false, browsers: ['Chrome'], singleRun: false, concurrency: Infinity }) }; 

test main.js

 var allTestFiles = []; var TEST_REGEXP = /(spec|test)\.js$/i; // Get a list of all the test files to include Object.keys(window.__karma__.files).forEach(function(file) { if (TEST_REGEXP.test(file)) { // Normalize paths to RequireJS module names. // If you require sub-dependencies of test files to be loaded as-is (requiring file extension) // then do not normalize the paths var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, ''); allTestFiles.push(normalizedTestModule); } }); require.config({ // Karma serves files under /base, which is the basePath from your config file baseUrl: '/base', // dynamically load all test files deps: allTestFiles, // we have to kickoff jasmine, as it is asynchronous callback: window.__karma__.start }); 
+4
source

All Articles