Javascript inspections don't know what JSTestDriver is any more

I recnetly updated WebStorm and now have a ton of errors in all my unit tests.

None of the assertion funtions in JSTestDriver are recognized. For example:

assertNotSame(undefined, foo);

now give me: "unresolved function or method assertNotSame".

I don't think this used to happen.

24 comments
Comment actions Permalink

Hi Bruce,

Please try File | Invalidate caches -- usually helps with unrecognized code after upgrades.

Also check that corresponding plugin is enabled.

0
Comment actions Permalink

Hey - thanks for the tip. It didn't work, however. I cleared caches, restarted, and checked that the JSTestDriver plugin in enabled.

0
Comment actions Permalink

Bruce, I can't reproduce it. I'll appreciate if you provide steps needed for the bug reproduction.

Workaround: open Settings dialog and select there JavaScript -> Libraries.
Find "JsTestDriver Assertion Framework" library and remove it.
After that you'll be prompted to "Add JsTestDriver assertion framework support" in the editor. Just add and it should work.
Hope this helps.

0
Comment actions Permalink

Well, there's the problem. I don't have jsTestDriver in the libraries panel, so I can't remove it. And I can't figure out the UI to add it.

0
Comment actions Permalink

What is your WebStorm version?
What is JsTestDriver plugin version installed?

0
Comment actions Permalink

WebStorm is 5.0.4, build 121.390
jsTestDriver in "change notes" says "Plugin version: 121.390, patched JstTestDriver-1.3.5"

0
Comment actions Permalink

Thanks. OK, close WebStorm, locate .idea directory of your project (it should be in the root of your project).
Find there .idea/jsLibraryMappings.xml and edit it.
This file should contain following tag:

<file url="PROJECT" libraries="{JsTestDriver Assertion Framework}" />


Delete this whole xml tag, save file and start WebStorm.

0
Comment actions Permalink

The file has almost nothing in it already:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4" />


That's the entire file contents.
0
Comment actions Permalink

OK. Please paste here content of your  JsTestDriver test file where you see unresolved symbols.

0
Comment actions Permalink

Here is the whole file. I've marked the first few place with problems:


var exp = {};

// >> no problem here - WebStorm seems to know what TestCase is...
var fake = new TestCase('game', {
    "setUp": function () {
        'use strict';
        require([
            'models/Game'
        ], function () {
            exp.Game = require('models/Game');
            /** @type {function(string, string)} */
            assertNotSame(undefined, exp.Game);  // >>>>>>>> problem
        });
    },
    "tearDown" : function () {
        'use strict';
    },


     // Sanity test that module Game was loaded
    'test 1': function () {
        'use strict';
        assertNotSame(undefined, exp.Game);  // >>>>>>>> problem
    },

    // test that we can instantiate a Game
    'test 2': function () {
        'use strict';
        var g = new exp.Game.Game({});
       // var g = exp.Game.construct();
        assertInstanceOf(exp.Game.Game, g);  // >>>>>>>> problem
    },
    // test that we can instantiate a Game, and it is valid
    'test 3': function () {
        'use strict';
        var g = new exp.Game.Game({name: "mine", id: "foo"});
        assertTrue(g._testIsValid());  // >>>>>>>> problem
    },

    // test that we can instantiate a Game, and read back its name
    'test 4': function () {
        'use strict';
        var g = new exp.Game.Game({name: "mine", id: "foo"});
        assertTrue(g._testIsValid());  // >>>>>>>> problem
        var n = g.getName();
        assertEquals("mine", n);  // >>>>>>>> problem
        n = g.get('id');
        assertEquals("foo", n);  // >>>>>>>> problem
    },

   // test that we can make a game from our json
    'test 5': function () {
        'use strict';
        var id = "some game";
        var gm = _g.games[id];

        assertNotSame(undefined, gm);
        var g = exp.Game.fromJSON(id, gm);
        assertTrue(g._testIsValid());
    },
    // test that we can bookmark a game
    'test 6': function () {
        'use strict';
        var id = "One and One Story";
        var gm = _g.games[id];

        var g = exp.Game.fromJSON(id, gm);

        assertFalse(g.isBookmarked());
        g.bookmark(true);
        assertTrue(g.isBookmarked());
        g.bookmark(false);
        assertFalse(g.isBookmarked());

        g.bookmark(false);
        assertFalse(g.isBookmarked());
    }


});

0
Comment actions Permalink

Thanks.
What is your OS?
Please follow http://devnet.jetbrains.net/docs/DOC-181 and locate "config" directory.
Paste here content of config/options/applicationLibraries.xml .

0
Comment actions Permalink

I am using the current version of OSX.

So I look in ~/Preferences.  But when I go there there is no ntelliJIdeaXX folder under there.

0
Comment actions Permalink

So I look in ~/Preferences.  But when I go there there is no ntelliJIdeaXX folder under there.

Well .. try reading whole document:

For other products based on IntelliJ platform look for the product name instead of IntelliJIdea:

  • WebIde for WebStorm/PhpStorm
  • PyCharm
  • RubyMine
0
Comment actions Permalink

OK, in my Webide50 folder I have a bunch of folders: codesytels, colors, commandlinetools, etc...

But no folders called config. and I don't seem to have any files called "applicationLibraries.xml"

0
Comment actions Permalink

OK, in my Webide50 folder I have a bunch of folders: codesytels, colors, commandlinetools, etc...

But no folders called config.

Accordignly to the aforementioned document -- you already in that folder:

On Mac OS X IDEA uses the following directories:

  • Config: ~/Library/Preferences/IntelliJIdeaXX


and I don't seem to have any files called "applicationLibraries.xml"

That file should be in "options" subfolder (at least it is the case for Windows OS)

0
Comment actions Permalink

Well, I'm on OS-X, and that's not how I read the instructions, but in any case you are right. That is the correct location. And here is the contents:

<?xml version="1.0" encoding="UTF-8"?>
<application>
  <component name="libraryTable">
    <library name="Node.js v0.8.12 Core Modules" type="javaScript">
      <properties>
        <option name="frameworkName" value="Node.js Core Modules" />
        <option name="frameworkVersion" value="v0.8.12" />
      </properties>
      <CLASSES />
      <SOURCES>
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/readline.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/repl.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/tls.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/tty.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/sys.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/timers.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/vm.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/zlib.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/stream.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/string_decoder.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/domain.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/events.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/module.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/net.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/http.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/https.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/punycode.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/querystring.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/util.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/url.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/dgram.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/dns.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/constants.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/crypto.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/freelist.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/fs.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/cluster.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/console.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/buffer_ieee754.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/child_process.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/assert.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/buffer.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/_debugger.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/_linklist.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/path.js" />
        <root url="file://$USER_HOME$/Library/Caches/WebIde50/extLibs/nodejs-v0.8.12-src/core-modules-sources/lib/os.js" />
      </SOURCES>
    </library>
  </component>
</application>

0
Comment actions Permalink

Bruce, thanks for pasting this. Unfortunatelly it didn't help either.
OK, I've polished JsTestDriver inspection logic a little. Please install attached JsTestDriver plugin.

Open Settings dialog, select Plugins item.
Click Install plugin from disk... and select there saved JsTestDriver-121.411.zip .
After that restart WebStorm.
If the problem is still there please attach idea.log file (on the main menu Help | Reveal Log in Finder).



Attachment(s):
JsTestDriver-121.411.zip
0
Comment actions Permalink

Didn't work, although it did update the version to 121.411. It also gave me a warning the jstestdriver dpenends on an unknown plugin coverage. So I should try installing that I suppose.

Log is enclosed.

Update: I can't find any plugin in the repository called "coverage".



Attachment(s):
idea.log.zip
0
Comment actions Permalink

Don't worry about missing dependency - coverage plugin. Actually coverage plugin is built into WebStorm so this warning will be removed in future versions.

According to the idea.log JsTestDriver-121.411 plugin has been successfully installed for you.

Please check that 'Add JsTestDriver assertion framework support' inspection is enabled.
To accomplish that open Setting dialog, select there Inspections.
Expand JavaScript | JsTestDriver. Make sure 'Add JsTestDriver assertion framework support' inspection is enabled.
See attached screenshot.

After that open your JavaScript test in the editor and position the caret on "TestCase" function invocation.
Are you prompted there to add JsTestDriver support (as shown in an attached screenshot)?



Attachment(s):
add-jstestdriver-support-in-editor.png
Add-JsTestDriver-assertion-framework-support-inspection.png
0
Comment actions Permalink

Yeah, so it does prompt me to add support. But since I'm on a Mac it promts me to use command-F1. Unfortunatley command-F1 already does something on a mac, so I am unable to do this.

Is there a direct UI for doing this?

0
Comment actions Permalink

OK - If I diable command-F1 in the mac ctrl panel I can almost activate this. Now I get a blue popup with some stange grapic and it says "add jstestdriver framework?" followed by some graphic that I think means "depress some key that I won't tell you what it is".

But I can't figure out what key it wants me to press. Is it enter? shift enter? ???????

(so there are two issues. One is that command f1 is a bad command binding on a mac, because it already means mirror displays. The other issue is that once you do succeed in pressing the fucntion key, you get another popup that is completely cryptic.

So I am still stuck.

0
Comment actions Permalink

OK - I asked a mac guru. the cryptic symbol is (in human speak) alt-enter.

Now it works!!!!!!!!

Is the only way to turn on this feature really to hover over a work, press a reserved keyboard sequence, then alt-enter???????????

anyway, thanks!

0
Comment actions Permalink

Great! Good to know now it works for you.
Command F1 show an error or warning description at the caret.
⌥ Enter (also known as Option Enter) is equivalent for Alt+Enter. I don't think this cryptic symbol will be changed in future, because it's a commonly used key identifier in Mac world.
Please file an issue about Command+F1 in the http://youtrack.jetbrains.com/issues/WI#newissue=yes.

0

Please sign in to leave a comment.