Error: You need to include some adapter that implements __karma__.start method

后端 未结 26 1342
梦谈多话
梦谈多话 2020-12-01 11:53

I\'m trying to add some unit tests to one of my projects.

So far I\'ve installed and configured karma, and have installed jasmine. I\'ve one test file in my te

相关标签:
26条回答
  • 2020-12-01 12:14

    You need to run your karma run or whatever function in the folder where karma-conf.js is in.

    0 讨论(0)
  • 2020-12-01 12:15

    In my case, I was applying by mistake the commonjs preprocessor to the karma-* modules and the adapter.js from karma-chrome and karma-firefox was broken this way.

    Unfortunately, this is a very generic error.

    0 讨论(0)
  • 2020-12-01 12:15

    You need to configure your "my.conf.js" file, because it contains all the info to use to test your code.

    All what you need to write is this:

    The configuration file can be generated using karma init:

    $ karma init my.conf.js
    

    Which testing framework do you want to use? Press tab to list possible options. Enter to move to the next question.

    jasmine

    Do you want to use Require.js? This will add Require.js plugin. Press tab to list possible options. Enter to move to the next question.

    no

    Do you want to capture a browser automatically? Press tab to list possible options. Enter empty string to move to the next question.

    Chrome

    What is the location of your source and test files? You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js". Press Enter to move to the next question.

    *.js test/**/*.js

    Should any of the files included by the previous patterns be excluded? You can use glob patterns, eg. "**/*.swp".

    Press Enter to move to the next question.

    Do you want Karma to watch all the files and run the tests on change? Press tab to list possible options.

    yes

    Config file generated at "/Users/vojta/Code/karma/my.conf.js".

    0 讨论(0)
  • 2020-12-01 12:15

    You will have to specify the directory of karma.config.js when you run start karma.

    Try

    karma start karma.config.js

    0 讨论(0)
  • 2020-12-01 12:16

    I was not running karma start command from the path where my karma.conf.js was. I switched to that folder and ran the same command. Thats all

    0 讨论(0)
  • 2020-12-01 12:16

    I've been struggling with this too. What I came up to is that this error occurs because one of the following reasons

    • No test adapter installed or defined (frameworks property in karma.conf.js
    • No karma configuration found (ie, no karma.conf.js in current dir or no config file specified in command)

    My problem was that my config file was named karma.config.js instead of karma.conf.js.

    If you've installed the test adapter but it still doesn't work, try running karma init and go through the guided config setup.

    0 讨论(0)
提交回复
热议问题