-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jest cannot understand token "?" from @babel/plugin-proposal-optional-chaining #200
Comments
having the. same issue, tried:
to tell vue-jest to use babelConfig, but did not work... |
@zeroarst your |
I use vue-jest@3.0.6, still has this problem. vuejs/vue#11088 |
// jest.config.js
module.exports = {
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
'^~/(.*)$': '<rootDir>/$1',
'^vue$': 'vue/dist/vue.common.js',
},
moduleFileExtensions: ['js', 'vue', 'json'],
transform: {
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest',
},
globals: {
'vue-jest': {
templateCompiler: {
compiler: require('vue-template-babel-compiler')
}
}
}
} |
It doesnt work with jest > 28 with @vue/vue2-jest 28 |
I am the same. I have confirmed that it does not work with the following versions.
|
Upgrading to Jest 29 and related dependencies fixed the problem for us. Because Jest now uses Node instead of JSDom as the default environment I also had to tell Jest to use JSDom.
|
I was not aware that version 29 was out. |
Upgrading the version mentioned above helped |
Thanks upgrading from 28 to these versions fixed the issues. |
My project is Vue 2.x. I am using
@babel/plugin-proposal-optional-chaining
and I have a line of code in my component.vue file that uses "?"which works well when run the app. However, my unit tests are failing because it cannot recognize the token "?"
my
babel.config.js
my partial
package.json
:my
jest.config.js
I am not sure what is the correct way to make Jest to be able to recognize the plugins that I use for my project. I am thinking it is because the .vue file is processed by vue-jest which does not take babel config... if that is the case I don't know how to fix it...
The text was updated successfully, but these errors were encountered: