//其它比如Nodejs的require方法报错也是相同的道理
The same issue exists for many of the assertions (not just .contain)
使用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()".
主要原因是没有安装相关库文件(比如chai),所以webstorm不能识别到相应的方法。
以下是安装第3方库的方法,适用于(chai,node,async....)
To fix this code completion warning in Webstorm 10 ....
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
To fix this code completion warning in Webstorm 10 ....
- Files - Settings - Languages and Frameworks - Javascript - Libraries
- Download
- Change the drop selection from Official Libraries to 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