0

I have started my practice on LWC testing While i'm run this command:"npm run test:unit"

i am getting this error:Cannot find module '@salesforce/sfdx-lwc-jest/config'.

Error body is:

Error: Cannot find module '@salesforce/sfdx-lwc-jest/config'
Require stack:
- C:\Users\TEAMABSYZ-68\OneDrive\Documents\SimpleCalculator\jest.config.js
- C:\Users\TEAMABSYZ-68\OneDrive\Documents\SimpleCalculator\node_modules\jest-config\build\readConfigFileAndSetRootDir.js
- C:\Users\TEAMABSYZ-68\OneDrive\Documents\SimpleCalculator\node_modules\jest-config\build\index.js
- C:\Users\TEAMABSYZ-68\OneDrive\Documents\SimpleCalculator\node_modules\jest\node_modules\jest-cli\build\cli\index.js  
- C:\Users\TEAMABSYZ-68\OneDrive\Documents\SimpleCalculator\node_modules\jest\node_modules\jest-cli\bin\jest.js
- C:\Users\TEAMABSYZ-68\OneDrive\Documents\SimpleCalculator\node_modules\jest\bin\jest.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)      
    at Object.<anonymous> (C:\Users\TEAMABSYZ-68\OneDrive\Documents\SimpleCalculator\jest.config.js:1:24)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)  
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)

Can anyone tell why this is giving error and when it will give these type of errors?

Thanks inadvance.

0

It could be because you may not have config file. Check this document.

Add a jest.config.js file to the root of the Salesforce DX project as described here. You must add this file to run Jest from Visual Studio Code.

| improve this answer | |

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.