微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

istambul nyc在运行ava测试套件时无法检测到任何文件

如何解决istambul nyc在运行ava测试套件时无法检测到任何文件

开始尝试将nyc / istambul集成到我的ava测试套件中:

./node_modules/.bin/nyc --include modules/todo.js --es-modules ./node_modules/.bin/ava
  1 tests passed
  ----------|---------|----------|---------|---------|-------------------
  File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
  ----------|---------|----------|---------|---------|-------------------
  All files |       0 |        0 |       0 |       0 |                   
  ----------|---------|----------|---------|---------|-------------------

输出无法列出任何文件

如果我添加--all标志,即使测试涵盖了这两个功能,我也会得到以下结果:

ERROR: Coverage for lines (0%) does not meet global threshold (90%)
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
 todo.js  |       0 |        0 |       0 |       0 | 6-30              
----------|---------|----------|---------|---------|-------------------

因此,看起来ava测试工具未获得nyc测试工具的输出

简单的设置如下:

/* todo.js (uses ES6 modules) */

'use strict'

let data = []

function clear() {
    data = []
}

function add(item,qty = 1) {
    qty = Number(qty)
    if(isNaN(qty)) throw new Error('qty must be a number')
    data.push({item: item,qty: qty})
  return true
}

export { add,clear }
/* todo.spec.js */
import { add,clear } from './modules/todo.js'
import test from 'ava'

test('add a single item',test => {
  clear()
  const ok = add('bread')
  test.truthy(ok)
})

我尝试创建.nycrc.json文件,但这没有帮助:

{
  "check-coverage": true,"include": [
    "modules/todo.js"
  ],"reporter": ["text","html"]
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。