gpt4 book ai didi

javascript - node.js istanbul 和 jasmine 设置

转载 作者:搜寻专家 更新时间:2023-10-31 22:52:16 30 4
gpt4 key购买 nike

我无法让 istanbul 与 jasmine 一起工作:

这是我的目录结构

ttm-jira
- package.json
- spec
- jira-spec.js

我的 package.json 看起来像这样:

{
"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"
}
}

当我从我的 ttm-jira 文件夹运行 npm-test 时,我看到以下内容:

    > ttm-jira@1.0.0 test C:\SRM\node_modules\ttm-jira
> npm run code-coverage && npm run unit-test


> ttm-jira@1.0.0 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! ttm-jira@1.0.0 code-coverage: `istanbul cover --include-all-sources`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ttm-jira@1.0.0 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>

我怎样才能让它工作?

如果我从我的 ttm-jira 目录运行以下命令:

istanbul cover ./spec/jira-spec.js jasmine-node test

我收到以下消息:

    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>

或者当我这样做的时候

istanbul cover ./spec/jira-spec.js

我得到以下信息:

        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" (
^

最佳答案

格式为:

istanbul cover [options] test_script [-- test-script-options]

在你的情况下:

istanbul cover --include-all-sources jasmine-node

关于javascript - node.js istanbul 和 jasmine 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33741161/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com