Import Unexpected identifier + SyntaxError: Unexpected string
After days of struggling with this. I ended up by answering my question. Here I leave all my config files.
jest.config.js
process.env.VUE_CLI_BABEL_TARGET_NODE = true;process.env.VUE_CLI_BABEL_TRANSPILE_MODULES = true;module.exports = { moduleFileExtensions: [ 'js', 'jsx', 'json', 'vue' ], transform: { '^.+\\.vue$': '<rootDir>/node_modules/vue-jest', '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub', '^.+\\.jsx?$': 'babel-jest' }, transformIgnorePatterns: [ '/node_modules/' ], moduleNameMapper: { '^@/(.*)$': '<rootDir>/src/$1' }, snapshotSerializers: [ 'jest-serializer-vue' ], testMatch: [ '**/tests/**/*.test.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)' ], testURL: 'http://localhost/', watchPlugins: [ 'jest-watch-typeahead/filename', 'jest-watch-typeahead/testname' ] }
babel.config.js
module.exports = { presets: [ '@vue/app' ]}
NOTES
- I needed to add babel core bridge to be able to use @babel/core with vue-jest
- It's recommended to clear jest's cache after changing the file