Search code examples
intellij-ideaautocompletemocha.jswebstormchai

Can Webstorm play nice with Chai language chains?


I am using Mocha+Chai for a current Node.js project. My IDE is Webstorm 11.

Unfortunately, it seems Webstorm has no way of figuring out how language chains in Chai's should/expect are supposed to work. The following is commonplace:

enter image description here

I have tried explicitly setting both Chai and Chai-DefinetlyTyped as libraries for my project via Settings->Javascript->Libraries, but this does not resolve anything.

For the sake of tool support, I have considered dropping expect/should for assert instead, as this works perfectly. However, I very much prefer the style of expect/should, so it would be amazing to see a solution to this.


Solution

  • Problem is caused by weird dynamic way these chains are defined. As a workaround I can suggest using chai.d.ts:

    • Open "Settings | Languages & Frameworks | JavaScript | Libraries"
    • Click "Download..." button and select "TypeScript community stubs"
    • Find "chai" and click "Download and Install".