-
Notifications
You must be signed in to change notification settings - Fork 11
How to Setup Jest for LWC Testing
Install/Setup guide for Jest:
-
Download nodejs here: Node JS Install or use chocolately and nodist if you know what you're doing (this approach is a bit better imo): NodeJS Nodist Install Instructions
-
Install Jest CLI via the CLI using the command: npm install -g jest-cli (or npm install --save-dev jest-cli for a local project install)
-
You may need to change your execution policy since jest doesn't register as a known Windows Package currently. Open powershell as an admin and enter the following command: Set-ExecutionPolicy Unrestricted a) When prompted, type the value A and then hit enter
-
Create a top level folder in your project called __tests__
-
Create tests in that folder and name them [fileYouAreTesting].test.js
-
Use the cli command jest --watch to have jest automatically run tests when they get updated