7

I'm trying to set up Jest for LWC. I have looked at the documentation and I have looked at the LWC website. Both of them refer to different packages for Jest installation. Which one should I use? and why?

1 Answer 1

5

As per my understanding after reading the docs,

sfdx-lwc-jest

  1. sfdx-lwc-jest works in Salesforce DX projects only.
  2. sfdx-lwc-jest, sets up all the necessary Jest configurations for a Salesforce DX project.

lwc/jest-preset

According to npm, Tools to assist with testing Lightning Web Components (LWC) with Jest. This project provides 2 services: preset Jest configuration for testing Lightning web components, and stubs for common external libraries used in Lightning web components.

After reading this Blog, @salesforce/lwc-jest is wrapper command of @lwc/jest-preset @lwc/module-resolver @lwc/compiler @lwc/engine .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .