karma: "config.files.map is not a function" when passing --files option

Hi, It seems I am unable to instruct Karma to only run a particular file.

Is this not possible anymore (I saw a reference to this having been possible on Stack Overflow)?

$ karma run karma.conf.js --files=new Array\("tests/unit/frontend/specs/timeLeftSpec.js"\)

[2015-11-30 10:20:50.784] [DEBUG] config - Loading config /Users/vs/Kod/myproject/karma.conf.js
/Users/vs/Kod/myproject/node_modules/karma/lib/config.js:107
  config.files = config.files.map(createPatternObject).map(createPatternMapper(basePathResolve));
                              ^

TypeError: config.files.map is not a function
    at normalizeConfig (/Users/vs/Kod/myproject/node_modules/karma/lib/config.js:107:31)
    at Object.parseConfig (/Users/vs/Kod/myproject/node_modules/karma/lib/config.js:293:10)
    at Object.exports.run (/Users/vs/Kod/myproject/node_modules/karma/lib/runner.js:30:16)
    at Object.<anonymous> (/usr/local/share/npm/lib/node_modules/karma/bin/karma:22:39)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:117:18)

I imagine using this for allowing my IDE (PhpStorm) to run the Karma test for a file (in the IDE) whenever a test/implementation file changes.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 19 (6 by maintainers)

Most upvoted comments

Banging my head on the wall for a few hours of this now, I don’t get why karma needs to be this user-hostile to running a single test. Makes TDD a true pain edit: excruciating.

Banging my head on the wall for a few hours of this now, I don’t get why karma needs to be this user-hostile to running a single test. Makes TDD a true pain edit: excruciating.

Comments like this are pretty maintainer-hostile. So if you need this so badly why not create a good PR with tests to solve the issue?

@dignifiedquire As a maintainer, I get it. However, the pain that I get for hours of searching for a solution and coming up with dead ends everywhere I look, that pain is pretty real too.

So if you need this so badly why not create a good PR with tests to solve the issue?

Maybe the reason I had to spend this much time to find a solution is that I wasn’t well versed at all in your library, at the level of not even being able to operate it. If I can’t even operate the thing, how much time of learning is it going to take me to end up fixing it and making a PR? Surely more than a few hours.

I just ran into this issue today. While I would like to find an easy way to specify an individual file, the other answer in the SO thread does give a way to test a describe block which is very helpful. For me, when I want to run tests on an individual file, calling out the name of a describe block is sufficient.

karma run -- --grep=nameOfDescribeBlock 

Right no worries it is just documented as an invalid option in a few places like stack overflow. Therefore many; including me went down a rabbit hole.

http://stackoverflow.com/questions/29150998/karma-running-a-single-test-file-from-command-line