使用WebStorm开发JavaScript时,chai断言库报错Unresolved function or method xxx()

使用WebStorm开发JavaScript时,chai断言库报错Unresolved function or method xxx()


The problem: While creating a test using chai assertions, you get the message "Undefined function or method  x() ". In this example:  Undefined function or method contain()".


Undefined function or method contain()

//其它比如Nodejs的require方法报错也是相同的道理
The same issue exists for many of the assertions (not just .contain)

主要原因是没有安装相关库文件(比如chai),所以webstorm不能识别到相应的方法。

以下是安装第3方库的方法,适用于(chai,node,async....)

To fix this code completion warning in  Webstorm 10 ....


  • Files  - Settings  - Languages and Frameworks  - Javascript - Libraries




  • Download



Download


  • Change the drop selection from Official Libraries to Typescript Community Stubs



  Official Libraries


Typescript community stubs


  • Find chai and select Download and Install





  • Enable chai-DefinitelyTyped 





  • Now, your code checking in Webstorm will recognize the syntax of the chai expectation library.





Notice that the .contain no longer shows as an undefined function or method warning.


Mike Caspar
Passionate About Agile

References:

chai assertion library
chai TypeScript community stub
WebStorm from JetBrains
meta-confirm
nodejs


参考文章:
https://github.com/chaijs/chai/issues/645
http://mike-caspar.blogspot.com/2015/08/webstorm-by-jetbrains-and-chai.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值