const { pathsToModuleNameMapper } = require('ts-jest/utils');
// In the following statement, replace `./tsconfig` with the path to your `tsconfig` file
// which contains the path mapping (ie the `compilerOptions.paths` option):
const { jsonc } = require('jsonc');
const { readFileSync } = require('fs');

const { compilerOptions } = jsonc.parse(readFileSync('./tsconfig.json', { encoding: 'utf8' }));

module.exports = {
    transform: {
        '^.+\\.tsx?$': 'ts-jest',
    },
    testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
    moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
    testEnvironment: './config/jest.environment.js',
    moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
        prefix: '<rootDir>',
    }),
    globals: {
        'ts-jest': {
            diagnostics: {
                ignoreCodes: ['TS151001'],
            },
        },
    },
};