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 249239 - Add Mocha as unit test runner
Summary: Add Mocha as unit test runner
Status: VERIFIED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Testing (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Theofanis Oikonomou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-09 17:38 UTC by Vladimir Riha
Modified: 2014-12-16 10:29 UTC (History)
0 users

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 Vladimir Riha 2014-12-09 17:38:26 UTC
As discussed today, it would be nice to have Mocha as a unit test runner (not only Selenium) so there would be 3 unit test runners: JSTDdriver, Karma and Mocha.

Thank you
Comment 1 Theofanis Oikonomou 2014-12-10 02:54:13 UTC
Changeset: 826614c5d6e8
Author:    Theofanis Oikonomou <theofanis@netbeans.org>
Date:      2014-12-10 03:53
Message:
Comment 2 Theofanis Oikonomou 2014-12-10 02:57:12 UTC
Added also autowatch support for unit tests (-w mocha option). If the option is checked in project properties, you only have to invoke the test project action once. Then go ahead and modify any test file under the unit tests folder and save. Unit tests are re-run automatically. Please let me know if something more can be done to improve this. Thanks
Comment 3 Quality Engineering 2014-12-11 12:59:04 UTC
Integrated into 'main-silver', will be available in build *201412111033* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/826614c5d6e8
User: Theofanis Oikonomou <theofanis@netbeans.org>
Log: Task #249239 - Add Mocha as unit test runner
Comment 4 Vladimir Riha 2014-12-11 19:35:08 UTC
Thank you. I might be doing something wrong but when I try Test action on project with Mocha unit tests, it fails with following

"/usr/local/bin/node" "/home/vriha/Documents/repo/web-main/javascript.nodejs/samples_src/Messages/node_modules/mocha/bin/mocha" "-w" "-t" "10000" "-R" "/home/vriha/Downloads/netbeans/webcommon/mocha/netbeans-reporter.js"

/home/vriha/Documents/repo/web-main/javascript.nodejs/samples_src/Messages/node_modules/mocha/lib/utils.js:356
if (!files.length) throw new Error("cannot resolve path (or pattern) '"
^
Error: cannot resolve path (or pattern) 'test'
at Object.lookupFiles (/home/vriha/Documents/repo/web-main/javascript.nodejs/samples_src/Messages/node_modules/mocha/lib/utils.js:356:32)
at runAgain (/home/vriha/Documents/repo/web-main/javascript.nodejs/samples_src/Messages/node_modules/mocha/bin/_mocha:302:30)
at Array.forEach (native)
at Object.<anonymous> (/home/vriha/Documents/repo/web-main/javascript.nodejs/samples_src/Messages/node_modules/mocha/bin/_mocha:301:6)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Done.



It seems like maybe there is no parameter to specify test folder?


Thanks


Product Version: NetBeans IDE Dev (Build 201412111033)
Java: 1.7.0_71; Java HotSpot(TM) Client VM 24.71-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_71-b14
System: Linux version 3.13.0-35-generic running on i386; UTF-8; en_US (nb)
Comment 5 Theofanis Oikonomou 2014-12-11 21:50:49 UTC
(In reply to Vladimir Riha from comment #4)
> 
> It seems like maybe there is no parameter to specify test folder?
> 
> 

I believe I know why you get this exception. I get identical one if I have Unit Tests Folder set in project properties to some folder other than "test". If I rename unit tests folder to "test" everything works fine as mocha by default looks for a folder named "test". Is this the case with you too? If yes then I will enhance mocha support to run all tests under whichever folder is set as Unit Tests Folder set in project properties.
Comment 6 Vladimir Riha 2014-12-11 22:00:58 UTC
Yes, you are right. The folder had a browser_tests name
Comment 7 Theofanis Oikonomou 2014-12-15 11:47:29 UTC
Changeset: 5fae8e0b3dcb
Author:    Theofanis Oikonomou <theofanis@netbeans.org>
Date:      2014-12-15 12:46
Message:
Comment 8 Quality Engineering 2014-12-16 04:21:50 UTC
Integrated into 'main-silver', will be available in build *201412160001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/5fae8e0b3dcb
User: Theofanis Oikonomou <theofanis@netbeans.org>
Log: Task #249239 - Add Mocha as unit test runner
Comment 9 Vladimir Riha 2014-12-16 10:29:44 UTC
Thank you, verified

Product Version: NetBeans IDE Dev (Build 201412160001)
Java: 1.8.0_11; Java HotSpot(TM) 64-Bit Server VM 25.11-b03
Runtime: Java(TM) SE Runtime Environment 1.8.0_11-b12
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)