Vue-cli: update jest to ^25

Created on 28 Jan 2020  路  10Comments  路  Source: vuejs/vue-cli

What problem does this feature solve?

Jest 25 was released a few days ago: https://jestjs.io/blog/2020/01/21/jest-25 . It would be appreciated if the vue-cli-plugin-jest would be updated to use that version instead of ^24.9.0

What does the proposed API look like?

Update the jest dependency to its latest version

unit-jest major

Most helpful comment

The Jest 26 is out: https://jestjs.io/blog/2020/05/05/jest-26

Among other important changes, it has an upgraded JSOM.

In my Vue app I use web-components, which do not work in JSDOM versions < 16. As an intermediate solution I am using jest-environment-jsdom-sixteen, but it would be great to have this integration built-in

All 10 comments

That will happen in the next major as it's a breaking change

didn't @vue/cli 4.0 already make a non breaking transition possible by pulling in jsdom v15?

If that's really the only breaking change, then yes. The release announcement wasn't too clear about this.

I thought so, but it turns out not the case. The jsdom-v15 thing only makes the transition easier but there are still breaking changes.

  1. Packages like ts-jest rely on hard-coded Jest version and it's not under our control.
  2. Seems Jest 25 breaks vue-jest test coverage https://github.com/vuejs/vue-jest/issues/217

In our current project we are running:

"@vue/cli-plugin-unit-jest": "4.3.1",
"jest": "25.5.2",
"ts-jest": "25.3.1",
"vue-jest": "3.0.5",

Fixing the jest version like this:

"resolutions": {
    "jest": "25.5.2"
  },

Which does seem to work for us, which would also imply that jest 25.* is not a breaking change?
Both test execution and code coverage is working.

Which does seem to work for us, which would also imply that jest 25.* is not a breaking change?

It's merely implies that your codebase doesn't use any part of jest that has a breaking change, and thus isn't affected.

Think about this use case:

package.json:

{
  "@vue/cli-plugin-unit-jest": "^4.1.0",
  "ts-jest": "^24.0.0"
}

ts-jest has hard-coded the allowed jest version range. So if we silently updated the underlying jest version to v25, it will throw. That will break the user's project.

The Jest 26 is out: https://jestjs.io/blog/2020/05/05/jest-26

Among other important changes, it has an upgraded JSOM.

In my Vue app I use web-components, which do not work in JSDOM versions < 16. As an intermediate solution I am using jest-environment-jsdom-sixteen, but it would be great to have this integration built-in

Agreed please upgrade to Jest 26 so we can test web components

I upgraded jest to v26 with this in my package.json file. (using Yarn)

  "resolutions": {
    "jest": "^26.6.3",
    "ts-jest": "^26.4.4",
    "babel-jest": "^26.6.3"
  }

Now I can use jset v26 while waiting for @vue/cli-plugin-unit-jest to be upgraded.

Was this page helpful?
0 / 5 - 0 ratings