module.exports = { preset: 'ts-jest', testEnvironment: 'jsdom', setupFilesAfterEnv: ['./jest.setup.js'], watchman: false, // tell Jest to handle `*.vue` files moduleFileExtensions: ['js', 'json', 'vue', 'ts'], // Paths // NOTE: Docs configuration does not work for our environment // https://kulshekhar.github.io/ts-jest/docs/27.1/getting-started/paths-mapping#jest-config-with-helper modulePaths: [''], moduleNameMapper: { '^~/(.*)$': '/$1', '^~~/(.*)$': '/$1', '^@/(.*)$': '/$1', '@shell/(.*)': '/shell/$1', '@pkg/(.*)': '/pkg/$1', '@components/(.*)': '/pkg/rancher-components/src/components/$1', '\\.(jpe?g|png|gif|webp|svg|mp4|webm|ogg|mp3|wav|flac|aac|woff2?|eot|ttf|otf)$': '/svgTransform.js', }, modulePathIgnorePatterns: [ '/cypress/', '/scripts/', '/docusaurus/', '/stories/', '/shell/scripts/', '/drone', '/.nuxt', '/.nuxt-prod', ], testPathIgnorePatterns: [ '/node_modules/', '(/.*)*/__tests__/utils/', ], // Babel transform: { '^.+\\.js$': '/node_modules/babel-jest', // process js with `babel-jest` '.*\\.(vue)$': '/node_modules/@vue/vue2-jest', // process `*.vue` files with `vue-jest` '^.+\\.tsx?$': 'ts-jest', // process `*.ts` files with `ts-jest` '^.+\\.svg$': '/svgTransform.js' // to mock `*.svg` files }, snapshotSerializers: ['/node_modules/jest-serializer-vue'], // Coverage coverageDirectory: '/coverage/unit', coverageReporters: ['json', 'text-summary'], collectCoverage: false, collectCoverageFrom: [ '/shell/**/*.{vue,ts,js}', '/pkg/rancher-components/src/components/**/*.{vue,ts,js}', '!/shell/scripts/', ], // Globals globals: { 'ts-jest': { isolatedModules: true } }, };