Guido Müller
Guido Müller

Reputation: 96

How to disable automatic Karma tests in Visual Studio

I have created a new Angular 2 web site. Now when I open this web site with Visual Studio 2015 (not VS Code) I see in the output window that Karma is continuously running all the tests it finds in the node_modules folder. I do not want to execute any automatic tests on code that I have not written. How can I switch this off?

Upvotes: 1

Views: 3258

Answers (2)

Drewness
Drewness

Reputation: 5072

If you want to disable the Karma Test Adapter completely then use @nihique answer. However, if you still want to use Karma for your tests but do not want it to run automatically then add/update these settings in Karma's configuration file, specifically autoWatch.

// karma.conf.js
module.exports = function(config) {
  config.set({
    // This is set to true by default
    autoWatch: false,
    //...
  });
};

Additionally, you can set exclude directories/files using minimatch patterns.

exclude: [
    // All files with "js" extension in all sub-directories
    '**/*.js',

    // Same as above, but excludes "jquery.js"
    '**/!(jquery).js',

    // In all sub-directories, all "min.js" and "spec.js" files
    '**/(min|spec).js'
]

Upvotes: 0

nihique
nihique

Reputation: 5788

Go to 'Tools > Extensions and Updates > Installed > All', find 'Karma Test Adapter', disable this extension and restart Visual studio

Upvotes: 3

Related Questions