sfdx-lwc-jest
sfdx-lwc-jest copied to clipboard
Error/Warning while running lwc-jest tests on a single newly created LWC component.
Description
Error/Warning while running lwc-jest tests on a single newly created LWC component.
console.error
[LWC error]: LWC WARNING: current engine is v5.0.2, but template was compiled with v5.1.0.
Please update your compiled code or LWC engine so that the versions match.
No further warnings will appear.
We didn't do anything specific to make this error appear, just created a new lwc and now we're getting this error.
Doesn't seem to be related to any of the sfdx-project.json
api version or anything like that.
Steps to Reproduce
The component has nothing specific, just a newer component we created.
# Command to repro
sfdx-lwc-jest -- --no-cache
Expected Results
Expected not to have to worry about the engine version of a template of a LWC created normally. And to be able to just run tests.
Actual Results
The tests still run, but this warning is displayed every time.
Version
- "@salesforce/sfdx-lwc-jest": "3.1.0",
- Node: 20.10.0
Can you run yarn why @lwc/engine-dom
or npm ls @lwc/engine-dom
(depending on whether you're using yarn
or npm
)?
It looks like LWC v5.1.0 is being pulled in somehow, whereas sfdx-lwc-jest
is currently on 5.0.2 We should go ahead and update that, but they could still get out of sync in the future if you have some other dependency pulling in LWC.
Also: please try updating to version 3.1.1.
Hey @nolanlawson realized I had not replied, my bad...
What is the expected development flow with sfdx-lwc-jest? Because I saw that you just released v.4.0.0 and it's marked as "latest" on npm, so our tools are trying to update to the latest version. However I see that the v4.0.0 contains a breaking change which updates LWC to v6.0.0?
While I seem to read online that the current release of Salesforce Spring '24 is running LWC v5 and not v6. (source: https://github.com/salesforce/lwc/releases/tag/v5.0.0)
I believe this may be related to this error because trying to update to v4.0.0 of sfdx-lwc-jest is triggering errors again in the CI like the following:
console.error
[LWC error]: LWC WARNING: current engine is v6.1.1, but template was compiled with v5.3.0.
Please update your compiled code or LWC engine so that the versions match.
No further warnings will appear.
Shouldn't the releases of sfdx-lwc-jest that are ahead of the current release of Salesforce be tagged with something else than latest
to avoid these compatibility issues between the different LWC engine versions?
To be clear it doesn't break the tests, but it just looks alarming I guess?
@erocheleau This is explained in the README for this project:
The npm latest tag corresponds to the
latest
version of this repo, not necessarily Salesforce production versions.
As mentioned in the README, the expected flow is e.g.:
yarn add -D @salesforce/sfdx-lwc-jest@spring22
So if you are targeting the current release (Spring '24), you would use the spring24
tag.
BTW you can use Yarn resolutions or something if you need to force all LWC versions to be the same. There's also a discussion about overhauling the versioning system here: https://github.com/salesforce/sfdx-lwc-jest/issues/349