mcPetrson
mcPetrson

Reputation: 91

JSHint in WebStorm doesn't know protractor command "browser"

I'm trying to make test for AngularJS web page in WebStorm (using Jasmine and Protractor frameworks), I'm using JHint for code inspection...

All code is OK except one command: "browser", example of code:

describe('Test',function(){
    it('Open page',function(){
        browser.get('https://www.angularjs.org');
        browser.sleep(2000);
    });
});

JSHint is still highlighting errors with browser:

Problem synopsis JSHint: 'browser' is not defined. (W117)

Unresolved function or method sleep() at line 20

In JHint Environment I have enabled:

  1. Jasmine
  2. Node.js

In JavaScript Libraries I have enabled:

  1. Node.js Core
  2. angular-protractor-DefinitelyTyped
  3. jasmine-DefinitelyTyped
  4. selenium-webdriver-DefinitelyTyped

Does anybody know what do I have to enable or which Library do I have to download to make JSHint understand the "browser" command please?

Upvotes: 3

Views: 792

Answers (2)

lena
lena

Reputation: 93728

JSHint works on per-file basis and doesn't 'see' global variables defined in other files unless they are added to 'global' list. This can be done by either adding the corresponding comments (/* global browser*/) to your files - see http://www.jshint.com/docs/, or by adding variables/functions you'd like to use globally to the 'Predefined' list in WebStorm Preferences -> Languages & Frameworks -> Javascript -> Code Quality Tool -> JSHint -> Predefined (,separated).

Upvotes: 1

Paqman
Paqman

Reputation: 456

Do you have a .jshintrc file ?

{
    "globals": {
        "browser": false,
    },
    "jasmine": true
}

You can add browser as a global.

Upvotes: 2

Related Questions