File tree Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -28,17 +28,39 @@ Then in `jest.config.js` add `@launchdarkly/jest/{framework}` to setupFiles:
2828``` js
2929// jest.config.js
3030module .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+ // Welcome.test.tsx
39+ import React from 'react';
40+ import { render } from '@testing-library/react-native ';
41+ import {
42+ mockFlags,
43+ resetLDMocks,
44+ getLDClient,
45+ } from '@launchdarkly/js-core /tooling/jest';
46+ import Welcome from './Welcome';
47+
48+ afterEach(() => {
49+ resetLDMocks();
50+ });
51+
52+ test('evaluates a boolean flag', () => {
53+ mockFlags({ 'my-boolean-flag': true });
54+ const { getByText } = render(<Welcome />);
55+ expect(getByText('Flag value is true')).toBeTruthy();
56+ });
57+
58+ test('captures a track call', () => {
59+ const client = getLDClient(); // mocked client from LD jest tooling
60+ client.track('event-name', { foo: 'bar' });
61+ expect(client.track).toHaveBeenCalledWith('event-name', { foo: 'bar' });
62+ expect(client.track).toHaveBeenCalledTimes(1);
63+ });
4264
4365## Developing this package
4466
You can’t perform that action at this time.
0 commit comments