UNPKG

899 BMarkdownView Raw
1# @lwc/jest-transformer
2
3Compile Lightning web components for [Jest](https://facebook.github.io/jest/) tests.
4
5## About Jest Transformers
6
7[Jest transformers](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.
8
9The 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.
10
11
12## Installation
13
14`yarn add -D @lwc/jest-transformer`
15
16## Usage
17
18Update your `jest` config to point the transformer to this package:
19
20```json
21{
22 "jest": {
23 "moduleFileExtensions": ["js", "html"],
24 "transform": {
25 "^.+\\.(js|html|css)$": "@lwc/jest-transformer"
26 }
27 }
28}
29```