Skip to content
Snippets Groups Projects
Commit 50882517 authored by Chad Woolley's avatar Chad Woolley :one:
Browse files

Add missing Jest aliases to webpack

- This allows editors which do not parse Jest
  moduleNameMapper entries (like JetBrains IDEs)
  to properly resolve imports using these alises.
- Also reorganizes some existing imports and
  adds explanatory comments
parent 42506db1
No related branches found
No related tags found
1 merge request!90474Add missing Jest aliases to webpack
......@@ -158,7 +158,6 @@ const alias = {
images: path.join(ROOT_PATH, 'app/assets/images'),
vendor: path.join(ROOT_PATH, 'vendor/assets/javascripts'),
jquery$: 'jquery/dist/jquery.slim.js',
jest: path.join(ROOT_PATH, 'spec/frontend'),
shared_queries: path.join(ROOT_PATH, 'app/graphql/queries'),
// the following resolves files which are different between CE and EE
......@@ -175,6 +174,15 @@ const alias = {
ROOT_PATH,
'app/assets/javascripts/lib/utils/icons_path.js',
),
// test-environment-only aliases duplicated from Jest config
'spec/test_constants$': path.join(ROOT_PATH, 'spec/frontend/__helpers__/test_constants'),
ee_else_ce_jest: path.join(ROOT_PATH, 'spec/frontend'),
helpers: path.join(ROOT_PATH, 'spec/frontend/__helpers__'),
jest: path.join(ROOT_PATH, 'spec/frontend'),
test_fixtures: path.join(ROOT_PATH, 'tmp/tests/frontend/fixtures'),
test_fixtures_static: path.join(ROOT_PATH, 'spec/frontend/fixtures/static'),
test_helpers: path.join(ROOT_PATH, 'spec/frontend_integration/test_helpers'),
};
if (IS_EE) {
......@@ -184,10 +192,14 @@ if (IS_EE) {
ee_empty_states: path.join(ROOT_PATH, 'ee/app/views/shared/empty_states'),
ee_icons: path.join(ROOT_PATH, 'ee/app/views/shared/icons'),
ee_images: path.join(ROOT_PATH, 'ee/app/assets/images'),
ee_jest: path.join(ROOT_PATH, 'ee/spec/frontend'),
ee_else_ce: path.join(ROOT_PATH, 'ee/app/assets/javascripts'),
jh_else_ee: path.join(ROOT_PATH, 'ee/app/assets/javascripts'),
any_else_ce: path.join(ROOT_PATH, 'ee/app/assets/javascripts'),
// test-environment-only aliases duplicated from Jest config
ee_else_ce_jest: path.join(ROOT_PATH, 'ee/spec/frontend'),
ee_jest: path.join(ROOT_PATH, 'ee/spec/frontend'),
test_fixtures: path.join(ROOT_PATH, 'tmp/tests/frontend/fixtures-ee'),
});
}
......@@ -198,21 +210,13 @@ if (IS_JH) {
jh_empty_states: path.join(ROOT_PATH, 'jh/app/views/shared/empty_states'),
jh_icons: path.join(ROOT_PATH, 'jh/app/views/shared/icons'),
jh_images: path.join(ROOT_PATH, 'jh/app/assets/images'),
jh_jest: path.join(ROOT_PATH, 'jh/spec/frontend'),
// jh path alias https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74305#note_732793956
jh_else_ce: path.join(ROOT_PATH, 'jh/app/assets/javascripts'),
jh_else_ee: path.join(ROOT_PATH, 'jh/app/assets/javascripts'),
any_else_ce: path.join(ROOT_PATH, 'jh/app/assets/javascripts'),
});
}
if (!IS_PRODUCTION) {
const fixtureDir = IS_EE ? 'fixtures-ee' : 'fixtures';
Object.assign(alias, {
test_fixtures: path.join(ROOT_PATH, `tmp/tests/frontend/${fixtureDir}`),
test_fixtures_static: path.join(ROOT_PATH, 'spec/frontend/fixtures/static'),
test_helpers: path.join(ROOT_PATH, 'spec/frontend_integration/test_helpers'),
// test-environment-only aliases duplicated from Jest config
jh_jest: path.join(ROOT_PATH, 'jh/spec/frontend'),
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment