Melchia
Melchia

Reputation: 24234

Files containing only exports decreases the test coverage Jest

I'm using create-react-app which uses Jest for testing. I have index.js files containing exports lines like

export { default } from './App.component';

which decreases the test coverage of my application.

Q: How to test such files or at least ignore them?

Upvotes: 3

Views: 1962

Answers (1)

Pranita
Pranita

Reputation: 339

You can ignore these files using a collectCoverageFrom config in your jest configuration.

    {
       "jest": {
           collectCoverageFrom: [ 
              '<yourDirectoryStructure>/**/*.{js,jsx}', 
              '!<yourDirectoryStructure>/**/index.{js,jsx}',
           ]
       }
    }

Upvotes: 4

Related Questions