|
| 1 | +export const baseJestConfig = { |
| 2 | + preset: "ts-jest", |
| 3 | + extensionsToTreatAsEsm: [".ts"], |
| 4 | + transform: { |
| 5 | + "^.+\\.ts$": [ |
| 6 | + "ts-jest", |
| 7 | + { |
| 8 | + useESM: true, |
| 9 | + }, |
| 10 | + ], |
| 11 | + }, |
| 12 | + transformIgnorePatterns: [ |
| 13 | + "node_modules/(?!(@nhsdigital/nhs-notify-event-schemas-supplier-config)/)", |
| 14 | + ], |
| 15 | + |
| 16 | + // Automatically clear mock calls, instances, contexts and results before every test |
| 17 | + clearMocks: true, |
| 18 | + |
| 19 | + // Indicates whether the coverage information should be collected while executing the test |
| 20 | + collectCoverage: true, |
| 21 | + |
| 22 | + // The directory where Jest should output its coverage files |
| 23 | + coverageDirectory: "./.reports/unit/coverage", |
| 24 | + |
| 25 | + // Indicates which provider should be used to instrument code for coverage |
| 26 | + coverageProvider: "babel", |
| 27 | + |
| 28 | + coverageThreshold: { |
| 29 | + global: { |
| 30 | + branches: 100, |
| 31 | + functions: 100, |
| 32 | + lines: 100, |
| 33 | + statements: -10, |
| 34 | + }, |
| 35 | + }, |
| 36 | + |
| 37 | + coveragePathIgnorePatterns: ["/__tests__/"], |
| 38 | + testPathIgnorePatterns: [".build"], |
| 39 | + testMatch: ["**/?(*.)+(spec|test).[jt]s?(x)"], |
| 40 | + |
| 41 | + // Use this configuration option to add custom reporters to Jest |
| 42 | + reporters: [ |
| 43 | + "default", |
| 44 | + [ |
| 45 | + "jest-html-reporter", |
| 46 | + { |
| 47 | + pageTitle: "Test Report", |
| 48 | + outputPath: "./.reports/unit/test-report.html", |
| 49 | + includeFailureMsg: true, |
| 50 | + }, |
| 51 | + ], |
| 52 | + ], |
| 53 | + |
| 54 | + // The test environment that will be used for testing |
| 55 | + testEnvironment: "jsdom", |
| 56 | +}; |
| 57 | + |
| 58 | +const utilsJestConfig = { |
| 59 | + ...baseJestConfig, |
| 60 | + |
| 61 | + testEnvironment: "node", |
| 62 | + |
| 63 | + coveragePathIgnorePatterns: [ |
| 64 | + ...(baseJestConfig.coveragePathIgnorePatterns ?? []), |
| 65 | + "zod-validators.ts", |
| 66 | + ], |
| 67 | +}; |
| 68 | + |
| 69 | +export default utilsJestConfig; |
0 commit comments