1

I've installed jasmine in my project. Now when I write the following in *.spec.js:

describe(...)

I get the warning:

Unresolved function or method describe

I've read in this answer that I can add jasmine as a library and thought that this should fix it.

enter image description here

But it doesn't seem to work - the warning is still there. What am I missing?

Community
  • 1
  • 1
Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
  • if `jasmine` is downloaded in your `node-modules`, IntelliJ should pick that up and not show `Unresolved function...`. I just checked by Ctrl+clicking on a describe, led me to `jasmine-1.3.1.js` inside `node-modules/jasmine-nod/...` – tanmay May 11 '17 at 06:39
  • @tanmay, yeah, that what I expected, but it doesn't pick it up :(. I noticed you use `jasmine-node` instead of [jasmine-npm](https://github.com/jasmine/jasmine-npm). Is it a better choice? – Max Koretskyi May 11 '17 at 08:09
  • It's not maintained anymore (last commit in 2014).. you're better off with `jasmine-npm`.. also try checking `/node_modules` fully if you haven't already.. if that helps – tanmay May 11 '17 at 08:29
  • @tanmay, got it, thanks, I've figured out the problem. Check [my answer](http://stackoverflow.com/a/43910794/2545680) – Max Koretskyi May 11 '17 at 08:54

1 Answers1

1

The problem is with the way globals are defined in Jasmine:

  // returns object with `describe`, `it`... properties
  var jasmineInterface = jasmineRequire.interface(jasmine, env);

  extend(global, jasmineInterface);

If globals are defined in this way WebStorm can't pick them up. It seems to be capable to handle only simply case like top-level functions:

function describe() {}

It's still possible to have intelli-sense support by downloading and installing DefinitelyTyped package:

enter image description here

Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488