-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
feat: update jest to v27 #6627
feat: update jest to v27 #6627
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
// eslint-disable-next-line node/no-extraneous-require | ||
const semver = require('semver') | ||
|
||
let vueVersion = 2 | ||
try { | ||
// eslint-disable-next-line node/no-extraneous-require | ||
const Vue = require('vue') | ||
vueVersion = semver.major(Vue.version) | ||
} catch (e) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we need to load a different transformer for Vue 2 and Vue 3, I hacked this code to retrieve the Vue version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can require |
||
|
||
let vueJest = null | ||
try { | ||
vueJest = require.resolve('vue-jest') | ||
vueJest = require.resolve(`@vue/vue${vueVersion}-jest`) | ||
} catch (e) { | ||
throw new Error('Cannot resolve "vue-jest" module. Please make sure you have installed "vue-jest" as a dev dependency.') | ||
throw new Error(`Cannot resolve "@vue/vue${vueVersion}-jest" module. Please make sure you have installed "@vue/vue${vueVersion}-jest" as a dev dependency.`) | ||
} | ||
|
||
module.exports = { | ||
testEnvironment: 'jsdom', | ||
moduleFileExtensions: [ | ||
'js', | ||
'jsx', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const babelJest = require('babel-jest') | ||
const babelJest = require('babel-jest').default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. babel-jest is now published as an ESM module. |
||
|
||
module.exports = babelJest.createTransformer({ | ||
plugins: ['@babel/plugin-transform-modules-commonjs'], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the Vue 3 tests in this file. They should be placed in the
jestPluginVue3.spec.js
so that they'll have the correct test environment setup. I think I forgot to remove this test case and it's a surprise that it still passed…There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I removed them (I already had the same tests in
jestPlluginVue3.spec.js
), and CI is green, thanks.I don't see
jestPluginVue3.spec.js
on the CI though? Is it running?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! It's running in the
e2e
job: https://app.circleci.com/pipelines/github/vuejs/vue-cli/1150/workflows/da9c2263-d7d7-4b0e-8f91-4d1c90303cae/jobs/27395There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome then, it should be working.
The PR is ready for your review!