How can I ignore a file pattern for Jest code coverage?

I use an external JSON file to hold my Jest configuration and run it from my package.json using npm: jest --config jest.config.json --no-cache

jest.config.json

{
    "collectCoverage": true,
    "collectCoverageFrom": [
        "src/**/*.ts"
    ],
    "coveragePathIgnorePatterns": [
        "node_modules",
        "test-config",
        "interfaces",
        "jestGlobalMocks.ts",
        ".module.ts",
        "<rootDir>/src/app/main.ts",
        ".mock.ts"
    ],
    "coverageDirectory": "<rootDir>/coverage/",
    "coverageThreshold": {
        "global": {
            "branches": 20,
            "functions": 30,
            "lines": 50,
            "statements": 50
        }
    },
    "mapCoverage": true,
    "preset": "jest-preset-angular",
    "setupTestFrameworkScriptFile": "<rootDir>/src/setupJest.ts",

    "transformIgnorePatterns": [
        "<rootDir>/node_modules/(?!@ionic-native|@ionic|@ngrx|angular2-ui-switch|angularfire2|jest-cli)"
    ],
    "verbose": false
}

My coverage does not include the files listed in the “coveragePathIgnorePatterns”. Maybe the source line “/src/app/main.ts” is the entry you need.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)