diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000000..54682dfe31 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,40 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +module.exports = { + testMatch: ['/src/**/*.test.{js,jsx,ts,tsx}'], + moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'], + + testEnvironment: './src/test/custom-environment', + setupFilesAfterEnv: ['jest-extended/all', './src/test/setup.ts'], + + collectCoverageFrom: [ + 'src/**/*.{js,jsx,ts,tsx}', + '!**/node_modules/**', + '!src/types/libdef/**', + ], + + // Transform ESM modules to CommonJS for Jest + // These packages ship as pure ESM and need to be transformed by Babel + transformIgnorePatterns: [ + '/node_modules/(?!(query-string|decode-uri-component|iongraph-web|split-on-first|filter-obj|fetch-mock)/)', + ], + + // Mock static assets (images, CSS, etc.) + moduleNameMapper: { + '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ftl)$': + '/src/test/fixtures/mocks/file-mock.ts', + '\\.(css|less)$': '/src/test/fixtures/mocks/style-mock.ts', + }, + + globals: { + AVAILABLE_STAGING_LOCALES: null, + }, + + snapshotFormat: { + escapeString: true, + printBasicPrototype: true, + }, + verbose: false, +}; diff --git a/package.json b/package.json index b24112b9ab..8dd41cb830 100644 --- a/package.json +++ b/package.json @@ -194,39 +194,6 @@ "@types/react-splitter-layout/@types/react": "^18.3.26", "@types/trusted-types": "^2.0.7" }, - "jest": { - "collectCoverageFrom": [ - "src/**/*.{js,jsx,ts,tsx}", - "!**/node_modules/**", - "!src/types/libdef/**" - ], - "moduleFileExtensions": [ - "js", - "jsx", - "ts", - "tsx" - ], - "transformIgnorePatterns": [ - "/node_modules/(?!(query-string|decode-uri-component|iongraph-web|split-on-first|filter-obj|fetch-mock)/)" - ], - "moduleNameMapper": { - "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ftl)$": "/src/test/fixtures/mocks/file-mock.ts", - "\\.(css|less)$": "/src/test/fixtures/mocks/style-mock.ts" - }, - "setupFilesAfterEnv": [ - "jest-extended/all", - "./src/test/setup.ts" - ], - "globals": { - "AVAILABLE_STAGING_LOCALES": null - }, - "snapshotFormat": { - "escapeString": true, - "printBasicPrototype": true - }, - "testEnvironment": "./src/test/custom-environment", - "verbose": false - }, "husky": { "hooks": { "post-checkout": "node bin/post-checkout.js",