The README describes how to mock external components, but in my case for lightning/primitiveIcon it doesn't work. It works if you provide the full path to the js file in the mapped module path in jest.config.js.
● Test suite failed to run
Configuration error:
Could not locate module lightning/primitiveIcon mapped as:
/home/work/src/project/force-app/stdlib/jest-mocks/lightning/$1.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/^lightning\/(primitiveIcon)$/": "/home/work/src/project/force-app/stdlib/jest-mocks/lightning/$1"
},
"resolver": /home/work/src/project/node_modules/@salesforce/sfdx-lwc-jest/src/resolver.js
}
at createNoMappedModuleFoundError (node_modules/jest-resolve/build/resolver.js:900:17)
at Object.<anonymous> (force-app/stdlib/lwc/button/button.html.compiled:5:1)
Version
@salesforce/sfdx-lwc-jest: 1.1.2
Possible Solution
The solution is to add the js file name to the mapped module path:
Description
Steps to Reproduce
The README describes how to mock external components, but in my case for
lightning/primitiveIcon
it doesn't work. It works if you provide the full path to the js file in the mapped module path injest.config.js
.Expected Results
Should not throw a configuration error.
Actual Results
Version
Possible Solution
The solution is to add the js file name to the mapped module path: