简体   繁体   中英

Istanbul Code Coverage tool incredibly slow after updating from version 12 to version 14

We use the Istanbul code coverage tool with Mocha to execute our Javascript unit tests. This has been working fairly well for quite some time. But, we were using version 12.0 with Node 11. We are trying to update our build system to Node 14, and this caused the 'nyc' command line tool to break.

Updating our nyc package to 14.1.0 fixes the problem, but when used with Node 14, it has become incredibly slow - our unit tests/code coverage was executing in a few minutes in the build system and locally, and now takes upwards of 30 minutes to execute now.

Our command line looks like this:

> nyc --all true mocha --exclude test/browserBootStrap/index.js --require ignore-styles --exit --no-colors --timeout=20000 --require test/helper/bootstrap.js --recursive -R min

Our bootstrap mainly sets up a bunch of path variables for require and node, as well as some stub modules for unit testing "dependency injection". Our NYC configuration looks like this:

  "nyc": {
"reporter": [
  "cobertura"
],
"all": false,
"include": [
  "Content/**"
],
"exclude": [
  "node_modules/**",
  "Content/@types/**",
  "Content/bower_components/**",
  "Content/diagnostics/**",
  "Content/events/**",
  "Content/extenders/**",
  "Content/hosts/**",
  "Content/lib/**",
  "Content/nls/**",
  "Content/polyfills/**",
  "Content/remove/**",
  "Content/requirePlugins/**",
  "Content/security/**",
  "Content/storage/**",
  "Content/tutorials/**",
  "Content/tests/**",
  "test/**"
],
"extension": [
  ".ts"
],
"check-coverage": false,
"sourceMap": false,
"statements": 100,
"lines": 100,
"branches": 100,
"functions": 100
},

I attached the chrome debugger to this and it runs quickly, but it differed by command line when I did that, it excluded the "--all true" switch.

I looked into the "nyc" initialization code and it had a line that I changed to add some console logging

if (argv.all) { console.log("adding all files"); nyc.addAllFiles(); console.log("adding all files - done"); }

This is apparently the step that was taking so much time. The first log statement came out immediately, and the second one took forever to reach.

Does anyone know what sort of configuration I could change to get this to work better or what issue might be taking place here?

The answer here is that the new version adds all.js files, even though we generally intend on only scanning typescript files.

在此处输入图像描述

I am trying to add wildcards to the "exclude" list and this isn't working. Like "**/*.js" and such.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM