marchaos / jest-mock-extended

Type safe mocking extensions for Jest https://www.npmjs.com/package/jest-mock-extended
MIT License
810 stars 56 forks source link

Support Jest ^28 #88

Closed jlarmstrongiv closed 2 years ago

jlarmstrongiv commented 2 years ago
npm ERR! Could not resolve dependency:
npm ERR! peer jest@"^24.0.0 || ^25.0.0 || ^26.0.0 || ^27.0.0" from jest-mock-extended@2.0.5
npm ERR! node_modules/jest-mock-extended
npm ERR!   jest-mock-extended@"^2.0.5" from @configs/jest@1.0.0

Should be as easy as updating this line https://github.com/marchaos/jest-mock-extended/blob/master/package.json#L35

jlarmstrongiv commented 2 years ago

Workaround in package.json:

{
  "overrides": {
    "jest-mock-extended@2.0.5": {
      "jest": "^28.0.2"
    }
  },
}

Note

fahminlb33 commented 2 years ago

If you're using pnpm, you can use this script in .pnpmfile.cjs at the root of your project. This script will allow any version of jest, a temporary fix until jest-mock-extended supports Jest 28.

function readPackage(pkg, context) {
  if (pkg.name === 'jest-mock-extended') {
    pkg.peerDependencies['jest'] = '*';
  }

  return pkg;
}

module.exports = {
  hooks: {
    readPackage
  }
}