Gustavo Poletto
Gustavo Poletto

Reputation: 31

Jasmine - How to exclude node_modules from spec coverage

I'm in trouble excluding node_modules files from my spec_files option.

This is my jasmine.json config.

{ 
  "spec_dir": "packages", 
  "spec_files": [ "**/*[sS]pec.js" ], 
  "helpers": [ "helpers/**/*.js" ],     "stopSpecOnExpectationFailure": false, 
  "random": true 
}

the spec_dir is a directory with multiple node_projects, each one has their own node_modules folder.

I've tried add '!node_modules/**/*[sS]pec.js' on the spec_files array but didn't work.

Is that a bug? Because from what i read in the docs thats the way I can exclude files from spec coverage.

Thanks!

Upvotes: 1

Views: 739

Answers (1)

Renaud
Renaud

Reputation: 4668

I came across your issue and this other SO then realised I had the wrong version of jasmine running. Even though I had jasmine-core: 3.4.0 in my package.json, the output of node_modules/.bin/jasmine was still 2.8.0. Upon inspection of the node_modules/jasmine/package.json I realised the executable was coming from an older version of jasmine, required by another dependency (in my case, protractor).

tl;dr; npm i jasmine@~3.4.0 --save-dev should solve your issue

Upvotes: 1

Related Questions