Toolkit: Fix Cannot use "import statement outside" error in tests (#57071)
This commit is contained in:
@@ -30,6 +30,7 @@ const copyFiles = () => {
|
||||
'src/config/tsconfig.plugin.local.json',
|
||||
'src/config/eslint.plugin.js',
|
||||
'src/config/styles.mock.js',
|
||||
'src/config/jest.babel.config.js',
|
||||
'src/config/jest.plugin.config.local.js',
|
||||
'src/config/matchMedia.js',
|
||||
'src/config/react-inlinesvg.tsx',
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// Transform es modules to prevent `SyntaxError: Cannot use import statement outside a module`
|
||||
module.exports = { presets: [['@babel/preset-env', { targets: { esmodules: false, node: 'current' } }]] };
|
||||
@@ -83,7 +83,10 @@ export const jestConfig = (baseDir: string = process.cwd()) => {
|
||||
'<rootDir>/spec/**/*.{spec,test,jest}.{js,jsx,ts,tsx}',
|
||||
],
|
||||
transform: {
|
||||
'^.+\\.jsx?$': require.resolve('babel-jest'),
|
||||
'^.+\\.(js|jsx|mjs)$': [
|
||||
require.resolve('babel-jest'),
|
||||
{ configFile: path.resolve(__dirname, './jest.babel.config.js') },
|
||||
],
|
||||
'^.+\\.tsx?$': require.resolve('ts-jest'),
|
||||
},
|
||||
transformIgnorePatterns: [
|
||||
|
||||
Reference in New Issue
Block a user