text: // @ts-check
  
  const { defaults: tsPreset } = require('ts-jest/presets');
  const { pathsToModuleNameMapper } = require('ts-jest');
  
  const { getJestCachePath } = require('../../cache.config');
  
  const packageJson = require('./package.json');
  const { compilerOptions: baseTsConfig } = require('./tsconfig.json');
  
  // Take the paths from tsconfig automatically from base tsconfig.json
  // @link https://kulshekhar.github.io/ts-jest/docs/paths-mapping
  const getTsConfigBasePaths = () => {
    return baseTsConfig.paths
      ? pathsToModuleNameMapper(baseTsConfig.paths, {
          prefix: '<rootDir>/',
        })
      : {};
  };
  
  /** @typedef {import('ts-jest/dist/types')} */
  /** @type {import('@jest/types').Config.InitialOptions} */
  const config = {
    name: `${packageJson.name}:unit`,
    cacheDirectory: getJestCachePath(packageJson.name),
    testEnvironment: 'node',
    verbose: true,
    testTimeout: 15000,
    rootDir: './src',
    transform: {
      ...tsPreset.transform,
    },
    setupFiles: ['./setupTestEnv.js'],
    setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
    testMatch: ['<rootDir>/**/*.{spec,test}.{js,jsx,ts,tsx}'],
    moduleNameMapper: {
      // For @testing-library/react
      '^@/test-utils$': '<rootDir>/../config/jest/test-utils',
      '.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform',
      '\\.svg$': '<rootDir>/../config/jest/__mocks__/react-svgr-mock.js',
      ...getTsConfigBasePaths(),
    },
    // false by default, overrides in cli, ie: yarn test:unit --collect-coverage=true
    collectCoverage: false,
    coverageDirectory: '<rootDir>/../coverage',
    collectCoverageFrom: ['<rootDir>/**/*.{ts,tsx,js,jsx}', '!**/*.test.ts'],
    globals: {
      'ts-jest': {
        diagnostics: true,
        tsconfig: './tsconfig.jest.json',
      },
    },
  };
  
  module.exports = config;
  