Skip to content

Commit b5760c0

Browse files
committed
docs: update jest README with testing examples and removed react setup instructions that are not currently available.
1 parent 4e9ff6b commit b5760c0

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/tooling/jest/README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,31 @@ Then in `jest.config.js` add `@launchdarkly/jest/{framework}` to setupFiles:
2828
```js
2929
// jest.config.js
3030
module.exports = {
31-
// for react
32-
setupFiles: ['@launchdarkly/jest/react'],
33-
3431
// for react-native
3532
setupFiles: ['@launchdarkly/jest/react-native'],
3633
};
3734
```
3835

3936
## Quickstart
4037

41-
TODO:
38+
describe('Welcome component test', () => {
39+
afterEach(() => {
40+
resetLDMocks();
41+
});
42+
43+
test('mock boolean flag correctly', () => {
44+
mockFlags({ 'my-boolean-flag': true });
45+
render(<Welcome />);
46+
expect(screen.getByText('Flag value is true')).toBeTruthy();
47+
});
48+
49+
test('mock ldClient correctly', () => {
50+
const current = useLDClient();
51+
52+
current?.track('event');
53+
expect(current.track).toHaveBeenCalledTimes(1);
54+
});
55+
});
4256

4357
## Developing this package
4458

0 commit comments

Comments
 (0)