module.exports = {
  setupFilesAfterEnv: ['<rootDir>/setup-test-env.js'],
  transform: {
    '^.+\\.jsx?$': `<rootDir>/jest-preprocess.js`,
    '^.+\\.mjs$': `<rootDir>/jest-preprocess.js`,
    // eslint-disable-next-line no-dupe-keys
    '^.+\\.jsx?$': `<rootDir>../node_modules/gatsby-core-theme/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>../node_modules/gatsby-core-theme/src/components/atoms$1',
    '^~molecules(.*)$': '<rootDir>../node_modules/gatsby-core-theme/src/components/molecules$1',
    '^~organisms(.*)$': '<rootDir>../node_modules/gatsby-core-theme/src/components/organisms$1',
    '^~pages(.*)$': '<rootDir>../node_modules/gatsby-core-theme/src/components/pages$1',
    '^~helpers(.*)$': '<rootDir>../node_modules/gatsby-core-theme/src/helpers$1',
    '^~hooks(.*)$': '<rootDir>../node_modules/gatsby-core-theme/src/hooks$1',
    '^~tests(.*)$': '<rootDir>../node_modules/gatsby-core-theme/tests$1',
    '^~context(.*)$': '<rootDir>../node_modules/gatsby-core-theme/src/context$1',
    '^~images(.*)$': '<rootDir>../node_modules/gatsby-core-theme/src/images$1',
    '^~constants(.*)$': '<rootDir>../node_modules/gatsby-core-theme/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`],
  transformIgnorePatterns: [`node_modules/(?!gatsby-core-theme|gatsby-script|gatsby-link|gatsby|@gigmedia/enigma-utils)`],
  coveragePathIgnorePatterns: ['src/constants', 'src/components/atoms/admin/card/button'],
  globals: {
    __PATH_PREFIX__: ``,
  },
  testEnvironmentOptions: {
    url: `http://localhost`,
  },
  setupFiles: [`<rootDir>/loadershim.js`, '<rootDir>/tests/envVars.js'],
  testEnvironment: '<rootDir>/tests/custom-jest-environment.js',
  collectCoverage: true,
  coverageThreshold: {
    global: {
      statements: 87,
    },
  },
};
