Add troubleshooting guidelines for Jest's transformIgnorePatterns
Now that GitLab UI is tree-shakable, we have added bootstrap-vue
to Jest's transformIgnorePatterns
to prevent its chunks from being transformed. Without this change, we would see errors such as this one when running Jest:
FAIL spec/frontend/environments/folder/environments_folder_view_spec.js
● Test suite failed to run
/Users/paul/Projects/gitlab/gdk/gitlab/node_modules/bootstrap-vue/esm/index.js:10
import { installFactory } from './utils/plugins';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:471:17)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:513:25)
at Object.<anonymous> (node_modules/@gitlab/ui/dist/components/base/link/link.js:1:1)
at Object.<anonymous> (node_modules/@gitlab/ui/dist/index.js:1:1)
We should expect to see similar errors with some other GitLab UI dependencies that would then need to be added to the transformIgnorePatterns
property. Let's document this somewhere to make sure this can be addressed quickly when this happens.
Edited by Paul Gascou-Vaillancourt