Skip to content

Commit

Permalink
Merge pull request #498 from transcom/update_ff_docs
Browse files Browse the repository at this point in the history
FF added jest testing instruction
  • Loading branch information
loganwc committed May 9, 2024
2 parents d0ee6bf + 79f554a commit 8e1d8e8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/tools/feature-flags/how-to-use-feature-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,27 @@ export const MyThing = () => {
}
```
## Jest Testing Feature Flags
```javascript
import { isBooleanFlagEnabled } from 'utils/featureFlags';
```
Add the following block to the top of your test file:
```javascript
jest.mock('utils/featureFlags', () => ({
...jest.requireActual('utils/featureFlags'),
isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve(false)),
}));
```
You can mock the boolean value in your tests with:
```javascript
isBooleanFlagEnabled.mockImplementation(() => Promise.resolve(YOUR_BOOLEAN_VALUE_HERE))
```
## Deploying Feature Flags
Each deployed environment has its own feature flag configuration. The
Expand Down

0 comments on commit 8e1d8e8

Please sign in to comment.