Skip to content

Commit d16f4cb

Browse files
authored
docs: copyedit readme and remove sample code based on wire reform (#204)
* docs: copyedit and remove code based on wire reform * docs: run yarn format
1 parent fc065b0 commit d16f4cb

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

README.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ sfdx-lwc-jest -- --json
8989

9090
See the [Jest documentation](http://facebook.github.io/jest/docs/en/cli.html) for all CLI options.
9191

92-
## Debug mode
92+
## Debug Mode
9393

9494
Debug mode lets you easily debug your Jest tests.
9595

@@ -135,7 +135,7 @@ If you prefer to debug inside Visual Studio Code, follow these steps:
135135
- Add a `jest.config.js` file to the root of the Salesforce DX project as described [here](#overriding-jest-config). You must add this file to run Jest from Visual Studio Code.
136136
- To run tests, press F5 or select Debug > Start Debugging.
137137

138-
## Watch mode
138+
## Watch Mode
139139

140140
Watch mode causes Jest to monitor files for changes and rerun tests related to the changed files. This is a great way to rapidly make component and test changes while monitoring tests results.
141141

@@ -163,17 +163,17 @@ This package installs stubs for the `lightning` base components to the `src/ligh
163163

164164
For components from other namespaces, not in your local `lwc` directory, create your own mock and update the Jest config to map the name of these components to the mock file.
165165

166-
Let's go through an example. Given the following template, `helloWorld.html`, we want to test:
166+
Let's go through an example. We want to test the following template, `helloWorld.html`.
167167

168168
```html
169169
<template>
170170
Hello From a Lightning Web Component!
171-
<lightning-button onclick={doSomething}></lightning-button>
172-
<foo-fancy-button onclick={doSomethingElse}></foo-button>
171+
<lightning-button onclick="{doSomething}"></lightning-button>
172+
<foo-fancy-button onclick="{doSomethingElse}"></foo-fancy-button>
173173
</template>
174174
```
175175

176-
Because it's in the `lightning` namespace, the `lightning-button` just works. However, you must write some code to help the Jest resolver find the `foo-fancy-button component`. First, create a `jest.config.js` file at the root of the Salesforce DX project workspace and add the following:
176+
Because it's in the `lightning` namespace, the `lightning-button` just works. However, you must write some code to help the Jest resolver find the `foo-fancy-button` component. First, create a `jest.config.js` file at the root of the Salesforce DX project workspace and add the following:
177177

178178
```js
179179
const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');
@@ -185,7 +185,7 @@ module.exports = {
185185
};
186186
```
187187

188-
This tells Jest to map the import for `foo-fancy-button` to the provided file. Notice that the first dash is converted to a forward slash and the rest of the component name goes from kebab to camel case. The reason for the forward slash is because the module resolver treats everything before the first dash as the namespace. Here, `<rootDir>` maps to the root of the Salesforce DX workspace. Note that this file location is not required, just an example.
188+
This config tells Jest to map the import for `foo-fancy-button` to the provided file. Notice that the first dash is converted to a forward slash and the rest of the component name goes from kebab to camel case. The reason for the forward slash is because the module resolver treats everything before the first dash as the namespace. Here, `<rootDir>` maps to the root of the Salesforce DX workspace. Note that this file location is not required, just an example.
189189

190190
You also have the freedom to make these mock implementations as sophisticated or simple as you'd like. In this example, we'll keep `foo-fancy-button` simple with an empty template and no functionality in the `.js` file, but you can always add whatever markup you'd like or implement functionality like any other Lightning web component.
191191

@@ -209,12 +209,4 @@ export default class FancyButton extends LightningElement {
209209

210210
To provision data through `@wire` adapters in unit tests, use the APIs provided by [`@salesforce/wire-service-jest-util`](https://github.com/salesforce/wire-service-jest-util). These APIs are exposed through this package so you do not need to include another dependency in your package.json.
211211

212-
```js
213-
import {
214-
registerTestWireAdapter,
215-
registerLdsTestWireAdapter,
216-
registerApexTestWireAdapter,
217-
} from '@salesforce/sfdx-lwc-jest';
218-
```
219-
220212
See the `@salesforce/wire-service-jest-util` [README](https://github.com/salesforce/wire-service-jest-util/blob/master/README.md) for further documentation on these APIs.

0 commit comments

Comments
 (0)