From a5d4c5879f67fdada8ed52b6e1476ea9b706c9d1 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Wed, 10 Jul 2019 13:27:39 +0000 Subject: Workaround ESLint only resolving paths in test files --- jest.config.js | 11 ++++++++++- spec/frontend/error_tracking_settings/mock.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/jest.config.js b/jest.config.js index 84481642250..986b8465eef 100644 --- a/jest.config.js +++ b/jest.config.js @@ -15,9 +15,18 @@ if (process.env.CI) { ]); } +let testMatch = ['/spec/frontend/**/*_spec.js', '/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.path.includes('/eslint-import-resolver-jest/'); +if (isESLint) { + testMatch = testMatch.map(path => path.replace('_spec.js', '')); +} + // eslint-disable-next-line import/no-commonjs module.exports = { - testMatch: ['/spec/frontend/**/*_spec.js', '/ee/spec/frontend/**/*_spec.js'], + testMatch, moduleFileExtensions: ['js', 'json', 'vue'], moduleNameMapper: { '^~(/.*)$': '/app/assets/javascripts$1', diff --git a/spec/frontend/error_tracking_settings/mock.js b/spec/frontend/error_tracking_settings/mock.js index 42233f82d54..8c5bfd08beb 100644 --- a/spec/frontend/error_tracking_settings/mock.js +++ b/spec/frontend/error_tracking_settings/mock.js @@ -1,5 +1,5 @@ import createStore from '~/error_tracking_settings/store'; -import { TEST_HOST } from '../helpers/test_constants'; +import { TEST_HOST } from 'helpers/test_constants'; const defaultStore = createStore(); -- cgit v1.2.3