1

I'm trying to create a configuration file to run karma tests including Jasmine and requirejs, so I run karma init xyz.conf.js, and the script asks me:

  • What testing framework to use? I have only available jasmine, as expected
  • Do you want to use require.js? When this question appears, it gets automatically answered no and moves on to the next question

I suppose it must have something to do with a missing dependency. I've installed, in this order:

npm install karma --save-dev (0.13.16)
npm install jasmine --save-dev (2.4.1)
npm install karma-jasmine --save-dev (0.3.6)
npm install karma-chrome-launcher --save-dev (0.2.2)
npm install requirejs --save-dev (2.1.22)
npm install karma-requirejs --save-dev (0.2.2)

npm -g install karma-cli --save-dev (0.1.2)

NOTE: I've included the installed version number

Do I have something missing or misconfigured? What do I have to do so that karma init allows me to specify that I want to use Require.js? Can I solve it by modifying the .conf.js by hand?

JotaBe
  • 38,030
  • 8
  • 98
  • 117

2 Answers2

0

I'm not sure why the config process skipped the requirejs option, but you can manually add the requirejs framework to your karma config file. A config file I set up with requirejs has the following framework value:

frameworks: ['jasmine', 'requirejs']

However, there is probably some more configuration you'll have to do in order to get it to run properly. The docs for Karma have a section for configuring the test environment to run with requirejs: http://karma-runner.github.io/0.13/plus/requirejs.html

pieceOpiland
  • 361
  • 3
  • 10
  • Thanks for your answer. I got it working. However I had to manually change the .conf.js file, and take into account some other things which are not well documented in the link you provide in your answer, which I had already read.Unless someone has a better solution, I'll answer thequestion myself with some additional notes. – JotaBe Jan 01 '16 at 12:17
  • @JotaBe Any plans on replying with what you did? – Mike Cheel Jan 27 '16 at 21:23
0

I came across this and I think it is possibly a bug in the CLI on Windows.

When it is working you can select any framework (e.g. mocha, nunit, qunit, nodeunit) by pressing Tab (or using the ↑ and ↓ keys) on the first question "Which testing framework do you want to use ?".

When it is not working you can only select jasmine and hitting Enter will skip the Require.js question.

I don't know the exact steps, but I was able to get into the working state by hitting Enter through a few options then hitting Ctrl+C and running karma init again.

After repeating this a few times I got into the working state where I could select any framework and select Require.js.

Loe
  • 327
  • 2
  • 5