Has anyone encountered this kind of an error? We had a bunch of jest js files that were working a few months but now are failing. Can any JEST experts help?
Has anyone encountered this kind of an error? We had a bunch of jest js files that were working a few months but now are failing. Can any JEST experts help?
Best Answer
This was an unfortunate mismatch between dependencies of dependencies when using the base LWC Jest testing packages. More specifically, if you happen to get a
babel-preset-jest
version < 25.5.4 but are runningjest
version >= 25.5.4. The exact version of these dependencies probably depends on when you installed or upgraded your dependencies and what yourpackage-lock.json
oryarn.lock
look like.The fix is to upgrade all Jest related dependencies to be >= 25.5.4, or pin them all below. If you're using
@salesforce/sfdx-lwc-jest
to run your tests, this was fixed already in theprerelease
branch.This was fixed in the sfdx-lwc-jest project here: https://github.com/salesforce/sfdx-lwc-jest/pull/152