Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is karma or Webstorm crashing when using nested describe statements in a jasmine unit test? Error: Cannot read property * of undefined?
    primarykey
    data
    text
    <p>I am using WebStorm combined with karma to run Jasmine javaScript unit tests. <strong>If I have nested <code>describe</code> statements then karma is crashing</strong>, or maybe it's WebStorm crashing, I'm not sure. </p> <p>The karma error output says:</p> <blockquote> <p>ERROR [karma]: [TypeError: Cannot read property 'should return a Foo' of undefined]</p> </blockquote> <ul> <li>If I run the tests directly in Jasmine SpecRunner.html everything is fine and tests pass.</li> <li>If I remove nested <code>describe</code> statements then everything runs fine.</li> </ul> <p>Versions:</p> <ul> <li>OS X: 10.9 (13A603) </li> <li>WebStorm: 7.0.2 </li> <li>karma: 0.10.8 </li> <li>karma-jasmine: 0.1.4</li> <li>jasmine.js: jasmine-1.3.1</li> </ul> <p>What is causing it to crash?</p> <p><strong>Code and test:</strong></p> <pre><code>var Foo = function Foo(name) { this.name = name; }; Foo.prototype.bar = function bar() { return "Hello " + this.name; }; describe("Foo", function () { describe("constructor", function () { it("should return a Foo", function () { var act, target; act = function () { target = new Foo("Gary"); }; expect(act).not.toThrow(); expect(target).not.toBeNull(); }); }); describe("bar", function () { it("should return a string like 'Hello' + name", function () { var target, actValue; target = new Foo("Gary"); actValue = target.bar(); expect(actValue).toBe("Hello Gary"); }); }); }); </code></pre> <p><strong>Karma error output:</strong></p> <pre><code>/usr/local/bin/node /Applications/WebStorm.app/plugins/js-karma/js_reporter/karma-intellij/lib/intellijServer.js --karmaPackageDir=/usr/local/lib/node_modules/karma --configFile=/Users/Gary/Documents/DotBox/test/karma.conf.js --coverageTempDir=/private/var/folders/5m/hfxftkwx5fsdnxf3g3nn5_2m0000gn/T/karma-intellij-coverage-4959093687844631591.tmp INFO [karma]: Karma v0.10.8 server started at http://localhost:9876/ INFO [launcher]: Starting browser Chrome INFO [Chrome 31.0.1650 (Mac OS X 10.9.0)]: Connected on socket vWDSeE6uTpA6RpuH05Bq INFO [watcher]: Changed file "/Users/Gary/Documents/DotBox/test/fooSpec.js". ERROR [karma]: [TypeError: Cannot read property 'should return a Foo' of undefined] TypeError: Cannot read property 'should return a Foo' of undefined at createSpecNode (/Applications/WebStorm.app/plugins/js-karma/js_reporter/karma-intellij/lib/intellijReporter.js:51:37) at IntellijReporter.onSpecComplete (/Applications/WebStorm.app/plugins/js-karma/js_reporter/karma-intellij/lib/intellijReporter.js:190:20) at EventEmitter.emit (events.js:98:17) at onResult (/usr/local/lib/node_modules/karma/lib/browser.js:177:13) at Socket.EventEmitter.emit [as $emit] (events.js:117:20) at SocketNamespace.handlePacket (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/namespace.js:335:22) at Manager.onClientMessage (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/manager.js:488:38) at WebSocket.Transport.onMessage (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transport.js:387:20) at Parser.&lt;anonymous&gt; (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:39:10) at Parser.EventEmitter.emit (events.js:95:17) at finish (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:288:16) at Parser.expectHandler (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:299:15) at Parser.add (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:466:24) at Parser.expect (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:499:10) at Parser.&lt;anonymous&gt; (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:298:18) at Parser.add (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:466:24) at Parser.expect (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:499:10) at expectData (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:296:16) at Parser.&lt;anonymous&gt; (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:317:11) at Parser.add (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:466:24) at Parser.expect (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:499:10) at Parser.opcodeHandlers.1 (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:316:14) at Parser.processPacket (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:533:8) at Parser.add (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:466:24) at Socket.&lt;anonymous&gt; (/usr/local/lib/node_modules/karma/node_modules/socket.io/lib/transports/websocket/hybi-16.js:141:17) at Socket.EventEmitter.emit (events.js:117:20) at Socket.&lt;anonymous&gt; (_stream_readable.js:746:14) at Socket.EventEmitter.emit (events.js:92:17) at emitReadable_ (_stream_readable.js:408:10) at emitReadable (_stream_readable.js:404:5) at readableAddChunk (_stream_readable.js:165:9) at Socket.Readable.push (_stream_readable.js:127:10) at TCP.onread (net.js:526:21) Process finished with exit code 1 </code></pre> <p><strong>SpecRunner Output</strong></p> <p><img src="https://i.stack.imgur.com/Autry.png" alt="SpecRunner Output"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload