debian-mirror-gitlab/jest.config.js

65 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-07-07 11:18:12 +05:30
const IS_EE = require('./config/helpers/is_ee_env');
2019-02-15 15:39:39 +05:30
const reporters = ['default'];
2019-07-31 22:56:46 +05:30
// To have consistent date time parsing both in local and CI environments we set
// the timezone of the Node process. https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/27738
process.env.TZ = 'GMT';
2019-02-15 15:39:39 +05:30
if (process.env.CI) {
reporters.push([
'jest-junit',
{
output: './junit_jest.xml',
},
]);
}
2019-09-30 21:07:59 +05:30
let testMatch = ['<rootDir>/spec/frontend/**/*_spec.js', '<rootDir>/ee/spec/frontend/**/*_spec.js'];
// workaround for eslint-import-resolver-jest only resolving in test files
// see https://github.com/JoinColony/eslint-import-resolver-jest#note
const isESLint = module.parent.filename.includes('/eslint-import-resolver-jest/');
if (isESLint) {
testMatch = testMatch.map(path => path.replace('_spec.js', ''));
}
2019-02-15 15:39:39 +05:30
// eslint-disable-next-line import/no-commonjs
module.exports = {
2019-09-30 21:07:59 +05:30
testMatch,
2019-02-15 15:39:39 +05:30
moduleFileExtensions: ['js', 'json', 'vue'],
moduleNameMapper: {
2019-07-07 11:18:12 +05:30
'^~(/.*)$': '<rootDir>/app/assets/javascripts$1',
'^ee(/.*)$': '<rootDir>/ee/app/assets/javascripts$1',
2019-12-04 20:38:33 +05:30
'^ee_component(/.*)$': IS_EE
? '<rootDir>/ee/app/assets/javascripts$1'
: '<rootDir>/app/assets/javascripts/vue_shared/components/empty_component.js',
2019-07-07 11:18:12 +05:30
'^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',
2019-07-31 22:56:46 +05:30
'emojis(/.*).json': '<rootDir>/fixtures/emojis$1.json',
2019-02-15 15:39:39 +05:30
},
collectCoverageFrom: ['<rootDir>/app/assets/javascripts/**/*.{js,vue}'],
coverageDirectory: '<rootDir>/coverage-frontend/',
coverageReporters: ['json', 'lcov', 'text-summary', 'clover'],
cacheDirectory: '<rootDir>/tmp/cache/jest',
modulePathIgnorePatterns: ['<rootDir>/.yarn-cache/'],
reporters,
2019-07-07 11:18:12 +05:30
setupFilesAfterEnv: ['<rootDir>/spec/frontend/test_setup.js'],
2019-02-15 15:39:39 +05:30
restoreMocks: true,
transform: {
2019-07-07 11:18:12 +05:30
'^.+\\.(gql|graphql)$': 'jest-transform-graphql',
2019-02-15 15:39:39 +05:30
'^.+\\.js$': 'babel-jest',
'^.+\\.vue$': 'vue-jest',
},
2019-07-07 11:18:12 +05:30
transformIgnorePatterns: ['node_modules/(?!(@gitlab/ui)/)'],
timers: 'fake',
testEnvironment: '<rootDir>/spec/frontend/environment.js',
testEnvironmentOptions: {
IS_EE,
},
2019-02-15 15:39:39 +05:30
};