Search code examples
unit-testingvitest

Vitest: how to exclude directory from coverage report?


How to exclude a directory from coverage report in vitest?

I'm looking for something like coveragePathIgnorePatterns option as it was in jest:

coveragePathIgnorePatterns: [
    '<rootDir>/src/foo.ts',
    '<rootDir>/src/bar.ts',
     ....
  ],

How could I do that in vitest.config.ts?


Solution

  • inside coverage you need to add exclude ignore pattern. then it will work. like this:

    in vite.config.ts

    {
    ...
      test: {
         ...,
         coverage: {
           provider: 'istanbul',
           exclude: ['src/config/**']
         }
    
      }
    }
    

    Don't add it outside the coverage.didn't work for me.