diff options
Diffstat (limited to 'jest.config.js')
-rw-r--r-- | jest.config.js | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/jest.config.js b/jest.config.js index c2a512e8afa..f5e589934e6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -28,25 +28,32 @@ if (isESLint) { testMatch = testMatch.map(path => path.replace('_spec.js', '')); } +const moduleNameMapper = { + '^~(/.*)$': '<rootDir>/app/assets/javascripts$1', + '^ee_component(/.*)$': + '<rootDir>/app/assets/javascripts/vue_shared/components/empty_component.js', + '^ee_else_ce(/.*)$': '<rootDir>/app/assets/javascripts$1', + '^helpers(/.*)$': '<rootDir>/spec/frontend/helpers$1', + '^vendor(/.*)$': '<rootDir>/vendor/assets/javascripts$1', + '\\.(jpg|jpeg|png|svg)$': '<rootDir>/spec/frontend/__mocks__/file_mock.js', + 'emojis(/.*).json': '<rootDir>/fixtures/emojis$1.json', + '^spec/test_constants$': '<rootDir>/spec/frontend/helpers/test_constants', +}; + +if (IS_EE) { + const rootDirEE = '<rootDir>/ee/app/assets/javascripts$1'; + Object.assign(moduleNameMapper, { + '^ee(/.*)$': rootDirEE, + '^ee_component(/.*)$': rootDirEE, + '^ee_else_ce(/.*)$': rootDirEE, + }); +} + // eslint-disable-next-line import/no-commonjs module.exports = { testMatch, moduleFileExtensions: ['js', 'json', 'vue'], - moduleNameMapper: { - '^~(/.*)$': '<rootDir>/app/assets/javascripts$1', - '^ee(/.*)$': '<rootDir>/ee/app/assets/javascripts$1', - '^ee_component(/.*)$': IS_EE - ? '<rootDir>/ee/app/assets/javascripts$1' - : '<rootDir>/app/assets/javascripts/vue_shared/components/empty_component.js', - '^ee_else_ce(/.*)$': IS_EE - ? '<rootDir>/ee/app/assets/javascripts$1' - : '<rootDir>/app/assets/javascripts$1', - '^helpers(/.*)$': '<rootDir>/spec/frontend/helpers$1', - '^vendor(/.*)$': '<rootDir>/vendor/assets/javascripts$1', - '\\.(jpg|jpeg|png|svg)$': '<rootDir>/spec/frontend/__mocks__/file_mock.js', - 'emojis(/.*).json': '<rootDir>/fixtures/emojis$1.json', - '^spec/test_constants$': '<rootDir>/spec/frontend/helpers/test_constants', - }, + moduleNameMapper, collectCoverageFrom: ['<rootDir>/app/assets/javascripts/**/*.{js,vue}'], coverageDirectory: '<rootDir>/coverage-frontend/', coverageReporters: ['json', 'lcov', 'text-summary', 'clover'], |