How can I get WebStorm to recognize Jasmine methods?

Joe White picture Joe White · Nov 13, 2011 · Viewed 40.5k times · Source

I have a node.js project that contains some Jasmine specifications. The specifications are in a spec/ subdirectory and have the .spec.coffee extension, as required by jasmine-node.

When I open one of my spec files in the WebStorm IDE, all the calls to beforeEach and describe and it are shown with blue squiggly underlines with the tooltip: "Unresolved function or method it()". So even though I'm using the 3.0 EAP and it's supposed to have some amount of Jasmine support, it's not automatically picking up on the fact that this is a Jasmine spec file.

I tried going into File > Settings > JavaScript Libraries, and adding Jasmine as a library (specifying the path to jasmine-2.0.0.rc1.js), and then going to the Usage Scope sub-page and checking "Jasmine" in the drop-down list next to "Project", but that had no effect -- the Jasmine methods still show up as unresolved.

How can I tell WebStorm that all files in a spec subdirectory, and/or all files with a .spec.coffee extension, are Jasmine tests, and have it recognize the Jasmine APIs those tests are using?

Answer

oujesky picture oujesky · Mar 26, 2014

You can use predefined JS library stubs in Webstorm/PHPStorm/Idea

  • Open File > Settings...
  • Select Languages & Frameworks > JavaScript > Libraries
  • Click on Download...

JavaScript Library settings

  • Swich to TypeScript community stubs
  • Find karma-jasmine (originally under the name jasmine) (If this does not work, try jasmine instead)
  • Click on Download and Install

enter image description here

I am using this setup with Jasmine 2.0