const tsconfig = require('./tsconfig.json');

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'jsdom',
  globals: {
    'ts-jest': {
      tsconfig: 'tsconfig.test.json',
    },
  },
  moduleNameMapper: Object.fromEntries(
    Object
      .entries(tsconfig.compilerOptions.paths)
      .map(([alias, paths]) => [alias, paths[0].replace('.', '<rootDir>')])
  ),
  collectCoverageFrom: [
    'src/modules/**/*.{ts,tsx}',
    '!src/modules/base-*/**/*.*',
  ],
};
