This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 244169 - Karma 0.12 does not work
Summary: Karma 0.12 does not work
Status: VERIFIED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Project (show other bugs)
Version: 8.0
Hardware: All All
: P2 normal with 1 vote (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks: 244531
  Show dependency tree
 
Reported: 2014-04-29 11:30 UTC by rokkieb
Modified: 2014-05-16 08:49 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rokkieb 2014-04-29 11:30:57 UTC
I'm trying got get karma to work, bu to no avail.
It eventually crashes with
ERROR [karma]: [TypeError: Cannot call method 'push' of undefined]

Steps to reproduce


Product Version: NetBeans IDE 8.0 (Build 201403101706)
Java:            1.7.0_51; OpenJDK 64-Bit Server VM 24.45-b08
Runtime:         OpenJDK Runtime Environment 1.7.0_51-b00
System:          Linux version 3.11.0-12-generic running on amd64; UTF-8; en_US (nb)

NodeJS:	   0.10.26
NPM:       1.4.3
Karma:     0.12.14
PanthomJS: 1.9.7

================================================================================

create new HTML5 project 'FooBar'

================================================================================

> cd path/to/FooBar
> npm init
name: (FooBar) 
version: (0.0.0) 
description: test for netbeans karma runner
entry point: (index.js) 
test command: karma start karma.conf.js
git repository: 
keywords: 
author: 
license: (ISC) 

> npm install karma karma-chrome-launcher karma-phantomjs-launcher karma-coverage karma-jasmine --save-dev
> sudo npm install -g karma-cli
> karma init

Which testing framework do you want to use ?
Press tab to list possible options. Enter to move to the next question.
> jasmine

Do you want to use Require.js ?
This will add Require.js plugin.
Press tab to list possible options. Enter to move to the next question.
> no

Do you want to capture any browsers automatically ?
Press tab to list possible options. Enter empty string to move to the next question.
> PhantomJS
> 

What is the location of your source and test files ?
You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js".
Enter empty string to move to the next question.
> test/**/*Spec.js
WARN [init]: There is no file matching this pattern.

> 

Should any of the files included by the previous patterns be excluded ?
You can use glob patterns, eg. "**/*.swp".
Enter empty string to move to the next question.
> 

Do you want Karma to watch all the files and run the tests on change ?
Press tab to list possible options.
> yes

================================================================================

> touch test/sanitySpec.js

add contents:
describe("Sanity", function() {
    it("succeeds", function() {
        expect(true).toEqual(true);
    });
});

================================================================================

Via terminal

> karma start karma.conf.js
INFO [karma]: Karma v0.12.14 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Linux)]: Connected on socket 23zVTo6Lhc6pISQOFchy with id 35303534
PhantomJS 1.9.7 (Linux): Executed 1 of 1 SUCCESS (0.038 secs / 0.002 secs)

This works

================================================================================

Now in netbeans

1. Project Properties
2. Javascript Testing > Karma
3. Karma:         path/to/FooBar/node_modules/karma/bin/karma
   Configuration: path/to/FooBar/karma.conf.js
   [x] Watch for file changes and rerun test automatically
4. OK
5. (right click) Karma > start

INFO [karma]: Karma v0.12.14 server started at http://localhost:9878/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Linux)]: Connected on socket EmELYRytETeohuPYJgW- with id 72617581
PhantomJS 1.9.7 (Linux): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR [karma]: [TypeError: Cannot call method 'push' of undefined]
TypeError: Cannot call method 'push' of undefined
    at onBrowserStart (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/lib/reporters/base.js:14:20)
    at null.<anonymous> (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/lib/events.js:15:22)
    at EventEmitter.emit (events.js:117:20)
    at onStart (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/lib/browser.js:128:13)
    at Socket.<anonymous> (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/lib/events.js:15:22)
    at Socket.EventEmitter.emit [as $emit] (events.js:117:20)
    at SocketNamespace.handlePacket (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/node_modules/socket.io/lib/namespace.js:335:22)
    at Manager.onClientMessage (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/node_modules/socket.io/lib/manager.js:488:38)
    at WebSocket.Transport.onMessage (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/node_modules/socket.io/lib/transport.js:387:20)
    at Parser.<anonymous> (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/node_modules/socket.io/lib/transports/websocket/default.js:36:10)

PhantomJS 1.9.7 (Linux): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
PhantomJS 1.9.7 (Linux): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR [karma]: [TypeError: Cannot call method 'push' of undefined]
TypeError: Cannot call method 'push' of undefined
    at onBrowserStart (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/lib/reporters/base.js:14:20)
    at null.<anonymous> (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/lib/events.js:15:22)
    at EventEmitter.emit (events.js:117:20)
    at onStart (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/lib/browser.js:128:13)
    at Socket.<anonymous> (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/lib/events.js:15:22)
    at Socket.EventEmitter.emit [as $emit] (events.js:117:20)
    at SocketNamespace.handlePacket (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/node_modules/socket.io/lib/namespace.js:335:22)
    at Manager.onClientMessage (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/node_modules/socket.io/lib/manager.js:488:38)
    at WebSocket.Transport.onMessage (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/node_modules/socket.io/lib/transport.js:387:20)
    at Parser.<anonymous> (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/node_modules/socket.io/lib/transports/websocket/default.js:36:10)
Done.

================================================================================

Point of interest:
1. Project Properties
2. Javascript Testing > Karma
3. [ ] Watch for file changes and rerun test automatically	<- turn this off
4. OK
5. (right click) Karma > start

INFO [karma]: Karma v0.12.14 server started at http://localhost:9878/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Linux)]: Connected on socket iXd-6wuBhMmDaSzRJ2ij with id 42621233

No errors, but also no tests
Tried the same with Chrome but the results are the same
Comment 1 Tomas Mysik 2014-04-29 11:40:45 UTC
(In reply to rokkieb from comment #0)
> ERROR [karma]: [TypeError: Cannot call method 'push' of undefined]
> TypeError: Cannot call method 'push' of undefined
>     at onBrowserStart
> (/home/rocco/Development/workspace/Personal/FooBar/node_modules/karma/lib/
> reporters/base.js:14:20)

This seems to me to be a bug/problem in Karma? Or maybe in our Karma plugin we use for reporting... Will have a look.

Thanks for reporting.
Comment 2 Vladimir Riha 2014-04-29 13:06:37 UTC
I'm afraid it is something related to the new Karma 0.12.X. This project uses Karma 0.12.14 and it doesn't work, if you use Karma 0.10 instead, it works like a charm. Here's a change log [1]. It's a shame Angular seed still uses 0.10, we would catch it sooner...



[1] https://github.com/karma-runner/karma/blob/master/CHANGELOG.md#v0120-2014-03-10
Comment 3 Tomas Mysik 2014-05-05 05:30:27 UTC
From e-mail from Vojta (in czech):

--------------------------------------------------
http://hg.netbeans.org/web-main/file/c53331d730a0/javascript.karma/release/karma/karma-netbeans-reporter/index.js#l61

self.browserResults je potřeba generovat v onBrowserStart(), podívej se na:
https://github.com/karma-runner/karma-junit-reporter/blob/edf56b9fab3cfadb42c6ba0e7a4b66c3c6532e19/index.js#L34-L44
--------------------------------------------------

Thanks.
Comment 4 Tomas Mysik 2014-05-06 09:32:08 UTC
Should be fixed now, please verify. Thanks.

http://hg.netbeans.org/web-main/rev/c460b5c95095
Comment 5 Quality Engineering 2014-05-07 02:17:14 UTC
Integrated into 'main-silver', will be available in build *201405070001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/c460b5c95095
User: Tomas Mysik <tmysik@netbeans.org>
Log: #244169 - Karma 0.12 does not work
Comment 6 rokkieb 2014-05-07 04:56:33 UTC
Works for me! Thank a bunch!

R.
Comment 7 Tomas Mysik 2014-05-07 05:42:14 UTC
(In reply to rokkieb from comment #6)
> Works for me! Thank a bunch!

You are welcome ;)
Comment 8 Vladimir Riha 2014-05-09 08:41:03 UTC
It seems like "watch for changes" does not work though. If you use the project setup from here and 
 - configure Karma in project properties to watch for changes
 - right click on project -> Test
 => test is executed, but output window of Karma ends with "Done" and it is not bold (so it indicates it is no longer running)

If you modify the sanitySpec.js, it won't re-run the test. If you now right click on project and select Test again, nothing happens (although IDE indicates Karma is running and from what I can say, it is true). One has to stop karma from IDE and then Test again.

If you stop Karma, restart IDE, test the project again (so it again "ends" with Done message in output), restart Karma
 => the test is executed, output window is bold (w/o Done message) and it seems OK. But once you modify the sanitySpec.js file and save it, the test is re-executed and after that, output window is again NOT bold and DOES contain Done msg.


There is nothing in IDE log or Karma output indicating some kind of problem.


Product Version: NetBeans IDE Dev (Build 201405090001)
Java: 1.8.0_05; Java HotSpot(TM) Client VM 25.5-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_05-b13
System: Linux version 3.2.0-60-generic-pae running on i386; UTF-8; en_US (nb)
Comment 9 Vladimir Riha 2014-05-09 08:43:14 UTC
(In reply to Vladimir Riha from comment #8)
> It seems like "watch for changes" does not work though. 

It is reproducible without this feature as well, simply try to invoke Test action several times. It works for me only twice, then again output window header is not bold anymore and contains Done messsage. Invoking Test action again does not work unless you manually stop/restart Karma before.
Comment 10 Tomas Mysik 2014-05-12 05:13:49 UTC
I will look at it. Thanks.
Comment 11 Tomas Mysik 2014-05-16 06:53:36 UTC
(In reply to Vladimir Riha from comment #9)
> It is reproducible without this feature as well, simply try to invoke Test
> action several times. It works for me only twice, then again output window
> header is not bold anymore and contains Done messsage. Invoking Test action
> again does not work unless you manually stop/restart Karma before.

This is not related to Karma 0.12, it is reproducible even with Karma 0.10. Láďo, could you please try to reproduce this steps on NB 8.0 FCS with Karma 0.10?

I have created issue #244531.

I suggest closing back this issue as FIXED and add it to the next patch (unless this scenario works in NB 8.0 FCS).

Thanks.
Comment 12 Vladimir Riha 2014-05-16 07:30:06 UTC
OK, thanks. Verified then