module.exports = {
  setupFilesAfterEnv: ['<rootDir>/setup-test-env.js'],
  transform: {
    '^.+\\.jsx?$': `<rootDir>/jest-preprocess.js`,
    '^.+\\.mjs$': `<rootDir>/jest-preprocess.js`,
  },
  moduleNameMapper: {
    '.+\\.(css|styl|less|sass|scss)$': `identity-obj-proxy`,
    '.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': `<rootDir>/__mocks__/file-mock.js`,
    // Aliases tests
    '^~atoms(.*)$': '<rootDir>/src/components/atoms$1',
    '^~molecules(.*)$': '<rootDir>/src/components/molecules$1',
    '^~organisms(.*)$': '<rootDir>/src/components/organisms$1',
    '^~pages(.*)$': '<rootDir>/src/components/pages$1',
    '^~helpers(.*)$': '<rootDir>/src/helpers$1',
    '^~hooks(.*)$': '<rootDir>/src/hooks$1',
    '^~tests(.*)$': '<rootDir>/tests$1',
    '^~context(.*)$': '<rootDir>/src/context$1',
    '^~constants(.*)$': '<rootDir>/src/constants$1',
    // JSON Data
    'data.json': '<rootDir>/__mocks__/search-data.json',
    '^gatsby-plugin-utils/(.*)$': [`gatsby-plugin-utils/dist/$1`, `gatsby-plugin-utils/$1`],
    '^gatsby-core-utils/(.*)$': `gatsby-core-utils/dist/$1`,
  },
  // testPathIgnorePatterns: [`node_modules`, `\\.cache`, `<rootDir>.*/public`],
  coveragePathIgnorePatterns: [
    'tests/helpers',
    'src/components/organisms/search',
    'src/components/molecules/search',
    'src/components/app.js',
  ],
  transformIgnorePatterns: [`node_modules/(?!(gatsby|gatsby-script|gatsby-link)/)`],
  globals: {
    __PATH_PREFIX__: ``,
  },
  testEnvironmentOptions: {
    url: `http://localhost`,
  },
  testEnvironment: '<rootDir>/tests/custom-jest-environment.js',
  setupFiles: [`<rootDir>/tests/loadershim.js`, '<rootDir>/tests/envVars.js'],
  collectCoverage: true,
  coverageThreshold: {
    global: {
      statements: 80,
    },
  },
};
