茉莉花-如何从规格范围中排除node_modules [英] Jasmine - How to exclude node_modules from spec coverage

查看:62
本文介绍了茉莉花-如何从规格范围中排除node_modules的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从spec_files选项中排除node_modules文件.

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

这是我的jasmine.json配置.

This is my jasmine.json config.

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

spec_dir是一个包含多个node_projects的目录,每个目录都有自己的node_modules文件夹.

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

我尝试在spec_files数组上添加'!node_modules/**/* [sS] pec.js',但是没有用.

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.

谢谢!

推荐答案

我遇到了您的 issue 这其他SO 然后意识到我运行的茉莉花版本错误.即使我的 package.json 中具有 jasmine-core:3.4.0 ,但 node_modules/.bin/jasmine 的输出仍然<代码> 2.8.0 .检查 node_modules/jasmine/package.json 后,我意识到可执行文件来自旧版本的jasmine,另一个依赖项(在我的情况下为量角器)需要该文件.

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 应该可以解决您的问题

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

这篇关于茉莉花-如何从规格范围中排除node_modules的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆