Mocha's describe "require() is missing" in WebStorm 11
I've just installed WebStorm 11 and created a new project, however WebStorm is saying that a require() is needed for the describe method:
I've added the definitely-types mocha library and the scope is for the test directory (which this file is in).
Edit: As noted in the comments, the actual issue addressed in this question is actually a bug in IntelliJ 15 / WebStorm 11 (see https://youtrack.jetbrains.com/issue/WEB-18768). I'm leaving the answer below because many people come here when searching for the solution provided.
The accepted answer is a sledgehammer approach to solving the problem. A better solution is to enable the mocha-DefinitelyTyped library for the test directory. Not only will this remove the erroneous inspection, it will provide better syntax highlighting.
From the description of the inspection:
If @types/mocha (used to be named mocha-DefinitelyTyped) is not in the list, click the Download… button, find ‘mocha’ in the ‘TypeScript community stubs’ section, select it, and click Download and Install:
The library is named just mocha in the list, but will convert into @types/mocha (prior to early 2019, it would convert to mocha-DefinitelyTyped) once imported.
Once you have mocha-DefinitelyTyped, uncheck its Enabled checkbox. Leaving it fully checked would enable it globally, even outside of tests, which would be inaccurate. Instead, we will manage its scope to be enabled only in your test directory. Click the Manage Scopes… button, find your test directory, click on the Library column, and select the ‘mocha-DefinitelyTyped’ entry. See the screenshot below.
Related ticket: WEB-18768
It's being tracked here, and the latest EAP (Early Access Preview), (Webstorm 2017.3.2 at the time of writing) fixes the issue. https://youtrack.jetbrains.com/oauth?state=%2Fissue%2FWEB-29725
I banged my head against the wall on this for hours, hopefully this helps someone else.
If you already have installed mocha globally and if it's still not work then try to remove all Run/Debug Configurations.
It will update npm runner and I hope it solves the problem.