diff --git a/jest.config.base.js b/jest.config.base.js index 745a179af6d809804853d9f6927a4e63a48877ec..5b7ab4d92763497978462de4527221a7e3963948 100644 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -1,7 +1,12 @@ const IS_EE = require('./config/helpers/is_ee_env'); const isESLint = require('./config/helpers/is_eslint'); -module.exports = (path) => { +module.exports = (path, options = {}) => { + const { + moduleNameMapper: extModuleNameMapper = {}, + moduleNameMapperEE: extModuleNameMapperEE = {}, + } = options; + const reporters = ['default']; // To have consistent date time parsing both in local and CI environments we set @@ -45,8 +50,7 @@ module.exports = (path) => { 'emojis(/.*).json': '<rootDir>/fixtures/emojis$1.json', '^spec/test_constants$': '<rootDir>/spec/frontend/__helpers__/test_constants', '^jest/(.*)$': '<rootDir>/spec/frontend/$1', - '^test_helpers(/.*)$': '<rootDir>/spec/frontend_integration/test_helpers$1', - '^ee_else_ce_test_helpers(/.*)$': '<rootDir>/spec/frontend_integration/test_helpers$1', + ...extModuleNameMapper, }; const collectCoverageFrom = ['<rootDir>/app/assets/javascripts/**/*.{js,vue}']; @@ -57,9 +61,9 @@ module.exports = (path) => { '^ee(/.*)$': rootDirEE, '^ee_component(/.*)$': rootDirEE, '^ee_else_ce(/.*)$': rootDirEE, - '^ee_else_ce_test_helpers(/.*)$': '<rootDir>/ee/spec/frontend_integration/test_helpers$1', '^ee_jest/(.*)$': '<rootDir>/ee/spec/frontend/$1', [TEST_FIXTURES_PATTERN]: '<rootDir>/tmp/tests/frontend/fixtures-ee$1', + ...extModuleNameMapperEE, }); collectCoverageFrom.push(rootDirEE.replace('$1', '/**/*.{js,vue}')); diff --git a/jest.config.integration.js b/jest.config.integration.js index 573002c1a34e48f4a50988b5cebe5d5f087eb4a4..d85e14fe218d7bc06303a45c002ef83361c23bd5 100644 --- a/jest.config.integration.js +++ b/jest.config.integration.js @@ -1,5 +1,13 @@ const baseConfig = require('./jest.config.base'); module.exports = { - ...baseConfig('spec/frontend_integration'), + ...baseConfig('spec/frontend_integration', { + moduleNameMapper: { + '^test_helpers(/.*)$': '<rootDir>/spec/frontend_integration/test_helpers$1', + '^ee_else_ce_test_helpers(/.*)$': '<rootDir>/spec/frontend_integration/test_helpers$1', + }, + moduleNameMapperEE: { + '^ee_else_ce_test_helpers(/.*)$': '<rootDir>/ee/spec/frontend_integration/test_helpers$1', + }, + }), };