I am unable to get istanbul to work with jasmine:
Here is my directory structure
ttm-jira
- package.json
- spec
- jira-spec.js
My package.json looks like this:
{
"name": "ttm-jira",
"version": "1.0.0",
"description": "nodeJS module to provide access to the JIRA REST API",
"author": {
"name": "...",
"url" : "...."
},
"main": "jira.js",
"private": true,
"repository": {
"type": "git",
"url" : "https://........git"
},
"bugs": {
"url" : "https://jira2........."
},
"scripts": {
"test" : "npm run code-coverage && npm run unit-test",
"unit-test" : "jasmine-node . --autotest --captureExceptions --watch",
"code-coverage": "istanbul cover --include-all-sources"
},
"devDependencies": {
"istanbul" : "^0.4.0",
"jasmine-node": "^1.14.5"
},
"dependencies": {
},
"engines": {
"node": ">=0.10.24"
}
}
When i run npm-test from my ttm-jira folder, i see this following:
> [email protected] test C:\SRM\node_modules\ttm-jira
> npm run code-coverage && npm run unit-test
> [email protected] code-coverage C:\SRM\node_modules\ttm-jira
> istanbul cover --include-all-sources
Need a filename argument for the cover command!
Try "istanbul help" for usage
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run
" "code-coverage"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! [email protected] code-coverage: `istanbul cover --include-all-sources`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] code-coverage script 'istanbul cover --include-all-sources'.
npm ERR! This is most likely a problem with the ttm-jira package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! istanbul cover --include-all-sources
npm ERR! You can get their info via:
npm ERR! npm owner ls ttm-jira
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\SRM\node_modules\ttm-jira\npm-debug.log
npm ERR! Test failed. See above for more details.
PS C:\SRM\node_modules\ttm-jira>
How can i make this work?
OR
if I run the following command from my ttm-jira directory:
istanbul cover ./spec/jira-spec.js jasmine-node test
I get the following message:
PS C:\SRM\node_modules\ttm-jira> istanbul cover -x ./spec/jira-spec.js jasmine-node test
No coverage information was collected, exit without writing coverage information
C:\Users\SW029693\AppData\Roaming\npm\jasmine-node.CMD:1
(function (exports, require, module, __filename, __dirname) { @IF EXIST "%~dp0\node.exe" (
^
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Object.Module._extensions.(anonymous function) [as .js] (C:\Users\SW029693\AppData\Roaming\npm\node_modules\istan
bul\lib\hook.js:109:37)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at runFn (C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\command\common\run-with-cover.js:122:16)
at C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\command\common\run-with-cover.js:251:17
at C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-matcher.js:68:16
PS C:\SRM\node_modules\ttm-jira> istanbul cover ./spec/jira-spec.js jasmine-node test
=============================================================================
Writing coverage object [C:\SRM\node_modules\ttm-jira\coverage\coverage.json]
Writing coverage reports at [C:\SRM\node_modules\ttm-jira\coverage]
=============================================================================
=============================== Coverage summary ===============================
Statements : 33.33% ( 1/3 )
Branches : 100% ( 0/0 )
Functions : 0% ( 0/2 )
Lines : 33.33% ( 1/3 )
================================================================================
C:\SRM\node_modules\ttm-jira\spec\jira-spec.js:9
__cov_Xe4IzZ5pgGmSS4dHihZPbQ.s['1']++;describe('A suite',function(){__cov_Xe4IzZ5pgGmSS4dHihZPbQ.f['1']++;__cov_Xe4IzZ5p
gGmSS4dHihZPbQ.s['2']++;it('contains spec with an expectation',function(){__cov_Xe4IzZ5pgGmSS4dHihZPbQ.f['2']++;__cov_Xe
4IzZ5pgGmSS4dHihZPbQ.s['3']++;expect(true).toBe(true);});});
^
ReferenceError: describe is not defined
at Object.<anonymous> (C:\SRM\node_modules\ttm-jira\spec\jira-spec.js:9:39)
at Module._compile (module.js:435:26)
at Object.Module._extensions.(anonymous function) [as .js] (C:\Users\SW029693\AppData\Roaming\npm\node_modules\istan
bul\lib\hook.js:107:24)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at runFn (C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\command\common\run-with-cover.js:122:16)
at C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\command\common\run-with-cover.js:251:17
at C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-matcher.js:68:16
at C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\node_modules\async\lib\async.js:52:16
PS C:\SRM\node_modules\ttm-jira> istanbul cover --include-all-sources jasmine-node test
No coverage information was collected, exit without writing coverage information
C:\Users\SW029693\AppData\Roaming\npm\jasmine-node.CMD:1
(function (exports, require, module, __filename, __dirname) { @IF EXIST "%~dp0\node.exe" (
^
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Object.Module._extensions.(anonymous function) [as .js] (C:\Users\SW029693\AppData\Roaming\npm\node_modules\istan
bul\lib\hook.js:109:37)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at runFn (C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\command\common\run-with-cover.js:122:16)
at C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\command\common\run-with-cover.js:251:17
at C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-matcher.js:68:16
PS C:\SRM\node_modules\ttm-jira>
OR when i do
istanbul cover ./spec/jira-spec.js
i get the following:
ReferenceError: describe is not defined
at Object.<anonymous> (C:\SRM\node_modules\ttm-jira\spec\jira-spec.js:9:39)
at Module._compile (module.js:435:26)
at Object.Module._extensions.(anonymous function) [as .js] (C:\Users\SW029693\AppData\Roaming\npm\node_modules\istan
bul\lib\hook.js:107:24)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at runFn (C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\command\common\run-with-cover.js:122:16)
at C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\command\common\run-with-cover.js:251:17
at C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-matcher.js:68:16
at C:\Users\SW029693\AppData\Roaming\npm\node_modules\istanbul\node_modules\async\lib\async.js:52:16
PS C:\SRM\node_modules\ttm-jira> istanbul cover --include-all-sources jasmine-node test
No coverage information was collected, exit without writing coverage information
C:\Users\SW029693\AppData\Roaming\npm\jasmine-node.CMD:1
(function (exports, require, module, __filename, __dirname) { @IF EXIST "%~dp0\node.exe" (
^