Skip to content

Commit cf66db8

Browse files
docs: add mocking tutorial
1 parent 1d9d89b commit cf66db8

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
id: mocking-data
3+
slug: /mocking-data
4+
title: Mocking data
5+
sidebar_position: 5
6+
tags:
7+
- Backend
8+
- MSW
9+
- Mocking
10+
- react-query
11+
- axios
12+
- react native
13+
- orval
14+
description: Mocking - check how to mock data from backend and display it for users
15+
---
16+
17+
# Mocking data
18+
19+
This template uses [MSW](https://mswjs.io/docs) to mock data.
20+
21+
Mocks are automatically generated with orval script - you can check [docs here](/api-connection)
22+
23+
## Enabling mocks
24+
25+
Go to `App.tsx` and change `ENABLE_MOCKED_SERVER` variable from false to true
26+
27+
```tsx title="/App.tsx"
28+
// FIXME: moking not working on mobile app - follow this discussion https://github.com/mswjs/msw/issues/2026
29+
// error-line
30+
const ENABLE_MOCKED_SERVER = false
31+
// success-line
32+
const ENABLE_MOCKED_SERVER = true
33+
34+
if (ENABLE_MOCKED_SERVER) {
35+
startMockedServer()
36+
}
37+
```
38+
39+
This will start msw server and api calls will be mocked!

0 commit comments

Comments
 (0)