fix: Правки в Jest конфиг для поддержки @ алиаса импортов

This commit is contained in:
Ilia Mashkov
2025-11-20 15:24:38 +03:00
parent 6b41f506a3
commit 5ef223d8d4
4 changed files with 333 additions and 2 deletions

View File

@@ -3,7 +3,13 @@
* https://jestjs.io/docs/configuration
*/
import path from 'path'
import path, { dirname } from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const PROJECT_ROOT = path.resolve(__dirname, '../..')
export default {
// Automatically clear mock calls, instances and results before every test
@@ -38,6 +44,7 @@ export default {
moduleNameMapper: {
'\\.(css|scss)$': 'identity-obj-proxy',
'\\.(svg)$': path.resolve(__dirname, 'JestEmptyComponent.tsx'),
'^@/(.*)$': path.resolve(PROJECT_ROOT, 'src/$1'),
},
// A list of paths to modules that run some code to configure or set up the testing framework before each test