Typescript 摩卡纽约和源地图
所以。我正试图弄清楚为什么这不起作用 我正在Typescript 摩卡纽约和源地图,typescript,mocha.js,source-maps,nyc,Typescript,Mocha.js,Source Maps,Nyc,所以。我正试图弄清楚为什么这不起作用 我正在src和tests目录中的文件中编写源代码和测试类型脚本代码。这些是*.ts和*.spec.ts文件 我使用npx-tsc将源文件和测试文件传输到build目录。因此,该目录现在包含*.js.,*.spec.js,*.js.map和*.spec.js.map文件类型 我现在如何设置摩卡和纽约来使用它? 我有以下几套 .nycrc.json { "extends": "@istanbuljs/nyc-config-typescript",
src
和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
但是,如果我在.nycrc.json
文件中将all
设置为false
,那么它不会抱怨。怎么了
我不想使用ts节点
或任何类似的东西,我已经传输了文件。
我不得不删除“扩展”:“@istanbuljs/nyc config typescript”
,并添加“重新映射后排除”:false,
我不得不删除
“extends”:“@istanbuljs/nyc config typescript”,
并添加“重新映射后排除”:false,
我在另一篇文章中给出了一个详细的示例,它可能是重复的:这似乎是相同的原因(纽约市没有为typescript正确配置。设置可能很棘手。我在这里的另一篇文章中给出了一个详细的示例,它可能是重复的:这似乎是相同的原因(纽约市没有为typescript正确配置。设置可能很棘手)。