Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 506
csvan Avatar asked Dec 23 '15 17:12

csvan


People also ask

Is WebStorm the same as IntelliJ?

Yes, IntelliJ Ultimate includes all WebStorm features. Most of them come as bundled plugins, but some features, e.g. Node. js support, are available as free plugins.

Who use WebStorm?

Who uses WebStorm? 1059 companies reportedly use WebStorm in their tech stacks, including Lyft, Tech Stack, and Accenture.

What is chai NodeJS?

Chai is an assertion library that is mostly used alongside Mocha. It can be used both as a BDD / TDD assertion library for NodeJS and can be paired with any JavaScript testing framework. It has several interfaces that a developer can choose from and looks much like writing tests in English sentences.


1 Answers

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".
like image 100
lena Avatar answered Oct 18 '22 03:10

lena