I admit that I'm being pedantic here. I have a Mocha test in WebStorm and WebStorm is complaining about describe()
and it()
not being a function type.
I have the mocha-definitelyTyped
library downloaded, and added to the tests
folder.
Running Mocha is fine. Why is WebStorm not resolving the describe
and it
methods?
Create a Mocha run configurationin the left-hand pane, and select Mocha from the list. The Run/Debug Configuration: Mocha dialog opens. Specify the Node interpreter to use and the location of the mocha package. Specify the working directory of the application.
If you just want to run one test from your entire list of test cases then, you can write only ahead of your test case. If you want to run all the test cases which are inside one describe section, then you can also write only to describe as well. describe.
From the description of the inspection:
When using libraries that define their own global symbols outside their visible JavaScript code (e.g. describe() in Mocha), it is recommended that you add the corresponding TypeScript type definition file as a JavaScript library in Preferences | Languages & Frameworks | JavaScript | Libraries.
Navigate to the above referenced preference and make sure the @types/mocha
(this was changed in early 2019 from mocha-DefinitelyTyped
. Either is OK.) library is in the list (don't select it). If it is not in the list, click the Download...
button, find mocha
there, and add it. Then click the Manage Scopes...
button, find your test directory, click on the library column, and select the @types/mocha
entry. See the screenshot below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With