首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mocha nyc和源地图

mocha nyc和源地图
EN

Stack Overflow用户
提问于 2019-06-13 14:14:54
回答 1查看 1.8K关注 0票数 1

所以。我想弄清楚为什么这不管用。

我正在srctests目录中的文件中编写源代码和测试tests代码。这些是*.ts*.spec.ts文件。

我使用npx tsc将源文件和测试文件传输到build目录。因此,这个目录现在包含*.js.*.spec.js*.js.map*.spec.js.map文件类型。

我现在如何设置摩卡和纽约来处理这个问题?

我有下面的一套。

.nycrc.json

代码语言:javascript
复制
{
    "extends": "@istanbuljs/nyc-config-typescript",
    "all": true,
    "branches": 0,
    "lines": 0,
    "functions": 0,
    "statements": 0,
    "check-coverage": true,
    "exclude": [".ignore", "coverage"],
    "report-dir": "./coverage/",
    "cache": false,
    "source-map": true,
    "produce-source-map": true
}

tsconfig.json:

代码语言:javascript
复制
{
    "compilerOptions": {
        "allowJs": true,
        "noImplicitAny": false,
        "strictNullChecks": true,
        "noImplicitThis": true,
        "alwaysStrict": true,
        "module": "commonjs",
        "target": "es2016",
        "lib": ["es2016"],
        "moduleResolution": "node",
        "types": ["mocha", "node"],
        "typeRoots": ["node_modules/@types"],
        "sourceMap": true,
        "outDir": "./build/",
        "skipLibCheck": true,
        "removeComments": false
    },
    "include": ["./**/*.ts", "./**/*.js"]
}

错误:

代码语言:javascript
复制
karl@karl-Dell-Precision-M3800:~/dev/escd$ NODE_ENV=test npx nyc --reporter=html --reporter=text mocha "./build/tests/**/*.js"
mappedCoverage.addStatement is not a function

但是,如果我在all文件中将false设置为false,那么它不会抱怨。出什么事啦?

我不想使用ts-node或任何类似的东西,我已经转移了文件。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-13 14:39:47

https://github.com/istanbuljs/nyc#source-map-support-for-pre-instrumented-codebases

我不得不删除"extends": "@istanbuljs/nyc-config-typescript",并添加"exclude-after-remap": false,

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56582509

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档