Closed BatemanVO closed 1 year ago
In addition to the above warning, a number of tests also fail when using Apex wire adapters because connector.connect is not a function
and connector.disconnect is not a function
errors are thrown when performing document.body.appendChild
and document.body.removeChild
on elements that have had wire methods executed.
Adding @lwc/engine-dom: "2.20.6"
to our repo's package.json
file appears to resolve the test failures and causes the @salesforce/sfdx-lwc-jest/node_modules/@lwc/engine-dom
directory to not be installed, though we are still seeing the warning of version mismatches.
While investigating why the warning was still showing after explicitly installing @lwc/engine-dom: "2.20.6"
, it may have actually been an issue with package-lock.json
specifying version mismatches.
Deleting package-lock.json
and the node_modules
directory, then reinstalling @salesforce/sfdx-lwc-jest
fresh appears to have resolved the issues.
Description
When installing
@salesforce/sfdx-lwc-jest
to the latest version (1.2.1), running any test causes the following error message to print to the console:Steps to Reproduce
rm -rf node_modules
npm i -D @salesforce/sfdx-lwc-jest
Run any LWC testExpected Results
No error should be printed to the console
Actual Results
A version mismatch is printed to the console
Version
@salesforce/sfdx-lwc-jest: 1.2.1
Possible Solution The issue appears to be that when
@salesforce/sfdx-lwc-jest
is installed, a dependency is installed of@lwc/engine-dom
that ultimately has a file in thedist/engine-dom.cjs.js
path with line 306 readingconst LWC_VERSION = "2.23.2"
. However, the path@salesforce/sfdx-lwc-jest/node_modules/@lwc/engine-dom/dist/engine-dom.cjs.js
has the same line readconst LWC_VERSION = "2.20.6"
.The reason is because the
package.json
file for@salesforce/sfdx-lwc-jest
specifies@lwc/engine-dom
to be version 2.20.6 exactly.