I am trying to run LWC Jest test, While i'm run this command:"sfdx force:lightning:lwc:test:run"

I am getting this error: 'sfdx-lwc-jest' is not recognized as an internal or external command,'.

Error body is:

C:\Testing\Auto59\test>sfdx force:lightning:lwc:test:run
'C:\Testing\Auto59\test\node_modules\@salesforce\sfdx-lwc-jest\bin\sfdx-lwc-jest' is not recognized as an internal or external command,
operable program or batch file.
Test run complete. Exited with status code: 1

Reference Link: https://github.com/salesforce/sfdx-plugin-lwc-test

1 Answer 1


This feature isn't installed by default.

You can add it via:

sfdx force:lightning:lwc:test:setup


npm install
npm install @salesforce/sfdx-lwc-jest --save-dev

(The first npm install is not a typo; this is used to install all other named packages in package.json and their dependencies.)

Once installed, the command should then work as documented.

You can read more about this in the documentation.

  • This is still not working, I am gettting the same error , package.json already the has script block "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "test": "npm run test:unit", "test:unit": "sfdx-lwc-jest", "test:unit:watch": "sfdx-lwc-jest --watch", "test:unit:debug": "sfdx-lwc-jest --debug", "test:unit:coverage": "sfdx-lwc-jest --coverage" }, Sep 15, 2020 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.