How do you launch Karma after installation?

I am trying to use karma for different viewing processes.

I set karma globally with

npm i -g karma 

Then ran karma start karma.conf.js and it worked.

Now I need to install karma locally inside the project using

 npm install karma 

This seems to be fine because I have karma in the folder in node_modules , however node_modules/karma/bin/karma does not seem to be an executable to run.

How do I start karma after locally locating it?

+5
source share
2 answers

To start Karma after using it locally:

 # Run Karma: $ ./node_modules/karma/bin/karma start 

Entering ./node_modules/karma/bin/karma start sucks, and therefore it may be useful for you to install karma-cli around the world. You will need to do this if you want to start Karma on Windows from the command line.

 $ npm install -g karma-cli 

Then you can start Karma with just karma from anywhere, and it will always launch the local version.

+2
source

To run locally on Windows (I am on Windows 10), I recommend adding the following to the package.json file:

  "scripts": { "test": "cd ./node_modules/karma/bin/ && karma start" }, 

Then from the command line, type npm run test

I prefer not to install cli globally for these tools and instead run them locally from my project using a script. That way, I can quickly find out which version is in the dev dependencies, and I don't have to worry about the global version being different from the local one.

 "devDependencies": { "karma": "^1.4.0" } 
+2
source

Source: https://habr.com/ru/post/1241229/


All Articles