Sets up Jest with ts-jest for unit and integration tests. Includes configurations for: - ESM support - Module resolution - Path aliasing - Adds unit tests to validate path utilities
32 lines
829 B
JavaScript
32 lines
829 B
JavaScript
import { createDefaultEsmPreset } from 'ts-jest';
|
|
|
|
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
const jestConfig = {
|
|
displayName: 'backend',
|
|
...createDefaultEsmPreset(),
|
|
testTimeout: 60000,
|
|
resolver: 'ts-jest-resolver',
|
|
testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'],
|
|
moduleFileExtensions: ['js', 'ts', 'json', 'node'],
|
|
testEnvironment: 'node',
|
|
extensionsToTreatAsEsm: ['.ts'],
|
|
moduleNameMapper: {
|
|
'^@openvidu-meet/typings$': '<rootDir>/../typings/src/index.ts',
|
|
'^(\\.{1,2}/.*)\\.js$': '$1' // Permite importar .js que resuelven a .ts
|
|
},
|
|
transform: {
|
|
'^.+\\.tsx?$': ['ts-jest', {
|
|
tsconfig: {
|
|
module: 'esnext',
|
|
moduleResolution: 'node16',
|
|
esModuleInterop: true,
|
|
allowSyntheticDefaultImports: true,
|
|
isolatedModules: true
|
|
},
|
|
useESM: true
|
|
}]
|
|
}
|
|
};
|
|
|
|
export default jestConfig;
|