@lwc/jest-transformer
Version:
Jest transformer for LWC and engine
33 lines (21 loc) • 1.07 kB
Markdown
Compile Lightning web components for [Jest](https://facebook.github.io/jest/) tests.
[](https://jestjs.io/docs/en/configuration#transform-object-string-string) modify source files in preparation for tests based on regular expressions. See Jest docs for more information.
The transformer modules in this package allow LWC developers to test components that reference `@salesforce` modules by transforming those `import` statements into assignment statements that work outside of a Salesforce application container.
`yarn add -D @lwc/jest-transformer`
Update your `jest` config to point the transformer to this package:
```json
{
"jest": {
"moduleFileExtensions": ["js", "html"],
"transform": {
"^.+\\.(js|html|css)$": "@lwc/jest-transformer"
}
}
}
```
For SSR testing, use the new transformer `@lwc/jest-transformer/ssr`, which compiles components to generate the compiled artifact used for SSR rendering.