const path = require('path') module.exports = { verbose: true, collectCoverageFrom: [ '**/*.{js,vue}', '!**/?(*.)+(spec|test|story).js?(x)', '!**/node_modules/**', '!**/.nuxt/**', '!**/storybook/**', '!**/coverage/**', '!**/config/**', '!**/maintenance/**', '!**/plugins/**', '!**/.eslintrc.js', '!**/.prettierrc.js', '!**/nuxt.config.js', ], coverageThreshold: { global: { lines: 83, }, }, coverageProvider: 'v8', // IMPORTANT: vueDemiSetup must be FIRST to ensure vue-demi is loaded from webapp's node_modules setupFiles: [ '/test/vueDemiSetup.js', '/test/registerContext.js', '/test/testSetup.js', ], transform: { '.*\\.(vue)$': '@vue/vue2-jest', '^.+\\.js$': 'babel-jest', '^.+\\.mjs$': 'babel-jest', }, // Transform ESM packages that Jest can't handle natively // Note: @ocelot-social/ui is NOT in the exception list because we load from dist/index.cjs // which is already CommonJS and doesn't need transformation transformIgnorePatterns: ['node_modules/(?!(vue-demi)/)', '/../packages/ui/'], testMatch: ['**/?(*.)+(spec|test).js?(x)'], modulePathIgnorePatterns: ['/dist/'], moduleNameMapper: { // IMPORTANT: vue-demi must be mapped BEFORE @ocelot-social/ui // This ensures that when the UI library's dist/index.cjs calls require("vue-demi"), // it gets webapp's Vue 2.7-configured vue-demi instead of UI library's Vue 3 one '^vue-demi$': path.resolve(__dirname, 'node_modules/vue-demi/lib/index.cjs'), // UI library - use mock that loads dist with correct vue-demi '^@ocelot-social/ui$': '/test/__mocks__/@ocelot-social/ui.js', '^@ocelot-social/ui/ocelot$': '/test/__mocks__/@ocelot-social/ui/ocelot.js', '^@ocelot-social/ui/style.css$': 'identity-obj-proxy', // Icon registry - mock to avoid require.context in Jest '^~/utils/iconRegistry$': '/test/__mocks__/iconRegistry.js', // Other mappings '\\.(svg)$': '/test/fileMock.js', '\\.(scss|css|less)$': 'identity-obj-proxy', '@mapbox/mapbox-gl-geocoder': 'identity-obj-proxy', 'vue2-datepicker/locale/undefined': 'vue2-datepicker/locale/en', '^@/(.*)$': '/src/$1', // jest is unable to build the styleguide on its own, as it uses webpack. '^@@/': '/../styleguide/dist/system.umd.min.js', '^~/(.*)$': '/$1', }, moduleFileExtensions: ['js', 'mjs', 'json', 'vue'], testEnvironment: 'jest-environment-jsdom', snapshotSerializers: ['jest-serializer-vue'], }