cenfun / monocart-coverage-reports

A code coverage tool to generate native V8 reports or Istanbul reports.
MIT License
28 stars 5 forks source link

[Question] How does "all" setting work? #59

Closed Aghassi closed 1 week ago

Aghassi commented 1 month ago

I've been trying to set it up but I find it does the inverse of what I expect. That is, when I run it covered files report 0 and uncovered files report 100. What I need clarity on is

  1. Where is "dir" suppose to be relative to? I'm using Bazel so where coverage run is not in the repo but it's elsewhere on disk
  2. What file extension am I suppose to target? I'm pretranspiling my code for jest and playwright so I have either CJS or webpack targets. Is the filters extension suppose to be the original file extension or the transpiled extension?

Thanks again! Really glad this tool exists, it's been a game changer for us.

cenfun commented 1 month ago
  1. Where is "dir" suppose to be relative to? I'm using Bazel so where coverage run is not in the repo but it's elsewhere on disk

it suppose to be relative to a dir of your source files. I'm not familiar with Bazel, but front-end builds generally use tools like webpack, esbuild, rollup, etc.

  1. What file extension am I suppose to target? I'm pretranspiling my code for jest and playwright so I have either CJS or webpack targets. Is the filters extension suppose to be the original file extension or the transpiled extension?

it should be the original file extension (the entryFilter is for the transpiled extension)

please use filter option, for example:

all: {
        dir: ['./src'],
        filter: {
            '**/ignored/**': false,
            '**/*.js': true
        }
    },

see minimatch usage: https://github.com/isaacs/minimatch or use funtion:

all: {
        dir: ['./src'],
        filter: (filePath)=> {
              // return true or false
        }
    },
Aghassi commented 3 weeks ago

OK that makes sense. We use all the same frontend tools you mentioned, Bazel is the top level orchestrating tool. The main difference is it copies files from the repo to a separate place on disk and then runs it's commands. So basically I need to try setting dir to an absolute path that is relative to where the original repo is is my understanding. I will try this today and report back