Jasmine - How to exclude node_modules from spec coverage

给你一囗甜甜゛ 提交于 2019-12-24 08:08:13

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/52937171/jasmine-how-to-exclude-node-modules-from-spec-coverage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!