lwc-jest-resolver
The default Jest resolver for finding lwc-* modules. This project leverages lwc-npm-resolver to allow LWC components to import modules by their shorthand. For example, lwc-engine can be imported simply as engine
.
For more info on resolvers see the Jest doc.
Requirements
- Node 8.x
- NPM 5.x
- Yarn >= 1.0.0
- Jest >= 21.x
Usage
This resolver will be included as part of LWCs preset Jest configuration. Follow directions on the official doc to use the presets. For example:
{
"jest": {
"preset": "lwc-jest-preset"
}
}
Alternatively, you can directly set the resolver in your config. For example:
{
"jest": {
"resolver": "lwc-jest-resolver"
}
}
If you are writing your own custom resolver, you can point Jest to your resolver and then delegate to this resolver directly, which in turn delegates to the Jest default resolver.