Mocha's describe “require() is missing” in WebStorm 11

前端 未结 5 1352
故里飘歌
故里飘歌 2020-12-23 20:27

I\'ve just installed WebStorm 11 and created a new project, however WebStorm is saying that a require() is needed for the describe method:

5条回答
  •  庸人自扰
    2020-12-23 21:23

    This is a new inspection introduced in v. 11 - it checks if the module used in code is referenced through require() statement. This inspection, indeed, is redundant for mocha tests ('describe' and other stuff don't need being required explicitly as they are added to global scope by Mocha). You can either disable this inspection or suppress it for 'describe', 'it', etc (see https://www.jetbrains.com/webstorm/help/suppressing-inspections.html). Another option: create a custom scope with your spec files excluded (Settings/Appearance & Behavior/Scopes), then choose this scope for 'Missing require() statement' inspection (Settings/Editor/Inspections/Javascript/Node.js).

    Related ticket: WEB-18768

提交回复
热议问题