所以。我想弄清楚为什么这不管用。
我正在src和tests目录中的文件中编写源代码和测试tests代码。这些是*.ts和*.spec.ts文件。
我使用npx tsc将源文件和测试文件传输到build目录。因此,这个目录现在包含*.js.、*.spec.js、*.js.map和*.spec.js.map文件类型。
我现在如何设置摩卡和纽约来处理这个问题?
我有下面的一套。
.nycrc.json
{
"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:
{
"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"]
}错误:
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或任何类似的东西,我已经转移了文件。
发布于 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,。
https://stackoverflow.com/questions/56582509
复制相似问题