用jasmine 2 / find spec \ support \ jasmine.json

时间:2016-03-21 18:57:14

标签: unit-testing karma-runner istanbul

我正在阅读业力 istanbul 的文档来设置代码覆盖率。我不确定我错过了什么。我包括了我用来计算这一步的所有内容,所以如果它长篇大论,我会道歉。

我尝试在我的npm包中运行启动脚本,但收到了错误消息

Error: Cannot find module 'c:\HA\VSTS\Applications\HA.Web.Main\spec\support\jasmine.json'

- https://karma-runner.github.io/0.8/config/coverage.html

- https://www.npmjs.com/package/istanbul#getting-started

这似乎应该是一个相当简单的过程。

在我的karma.conf文件中,我有karma-coverage

 plugins: {
   karma-coverage
]

我设置了一个报道记者对象

coverageReporter: {
    // disable code compaction when using instrumenter  * do not want ot minify output
    instrumenterOptions: {
        istanbul: { noCompact: true }
    },
    type: 'html',
    dir: 'coverage/'
},

在预处理器内部,我列出了我想要涵盖的文件

preprocessor: [     

 "../Scripts/src/modules/**/*.js": ['coverage']

]

该文档记录了Windows上的jasmine,并确定了脚本对象使用跨平台的必要性。

"scripts": {
    "test": "istanbul cover node_modules/jasmine/bin/jasmine.js"
},

我的节点模块中有茉莉花,所以不应该是个问题。

我跑去进一步确定可能出现的问题。

istanbul help config

但说实话,我现在不知道在这些对象中寻找什么

    verbose: false
instrumentation:
    root: .
    extensions:
        - .js
    default-excludes: true
    excludes: []
    embed-source: false
    variable: __coverage__
    compact: true
    preserve-comments: false
    complete-copy: false
    save-baseline: false
    baseline-file: ./coverage/coverage-baseline.json
    include-all-sources: false
    include-pid: false
    es-modules: false
reporting:
    print: summary
    reports:
        - lcov
    dir: ./coverage
    watermarks:
        statements: [50, 80]
        lines: [50, 80]
        functions: [50, 80]
        branches: [50, 80]
    report-config:
        clover: {file: clover.xml}
        cobertura: {file: cobertura-coverage.xml}
        json: {file: coverage-final.json}
        json-summary: {file: coverage-summary.json}
        lcovonly: {file: lcov.info}
        teamcity: {file: null, blockName: Code Coverage Summary}
        text: {file: null, maxCols: 0}
        text-lcov: {file: lcov.info}
        text-summary: {file: null}
hooks:
    hook-run-in-context: false
    post-require-hook: null
    handle-sigint: false
check:
    global:
        statements: 0
        lines: 0
        branches: 0
        functions: 0
        excludes: []
    each:
        statements: 0
        lines: 0
        branches: 0
        functions: 0
        excludes: []

1 个答案:

答案 0 :(得分:1)

您需要致电jasmine init来生成该文件。如果您在本地安装了jasmine,则需要致电:

node_modules/jasmine/bin/jasmine.js init