Skip to content
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

Error/Warning while running lwc-jest tests on a single newly created LWC component. #344

Open
erocheleau opened this issue Jan 8, 2024 · 4 comments

Comments

@erocheleau
Copy link

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
@nolanlawson
Copy link
Contributor

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.

@nolanlawson
Copy link
Contributor

nolanlawson commented Jan 11, 2024

Also: please try updating to version 3.1.1.

@erocheleau
Copy link
Author

erocheleau commented Feb 19, 2024

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?

@nolanlawson
Copy link
Contributor

nolanlawson commented Feb 20, 2024

@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: #349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants