https://github.com/ph-fritsche/example-react-act
https://github.com/ph-fritsche/example-react-act
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ph-fritsche/example-react-act
- Owner: ph-fritsche
- Created: 2023-02-16T10:35:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-16T11:52:37.000Z (over 2 years ago)
- Last Synced: 2025-02-28T16:36:24.061Z (3 months ago)
- Language: TypeScript
- Size: 38.1 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**Example code for the blog post at https://ph-fritsche.github.io/blog/post/react-act**
### Clone the repository and install dependencies
```
git clone https://github.com/ph-fritsche/example-react-act.git
cd example-react-act
yarn
```### Serve the example
```
yarn start
```### Run the tests
```
yarn test
```### Trigger the warning
Edit [src/MyCounter.test.tsx](https://github.com/ph-fritsche/example-react-act/blob/main/src/MyCounter.test.tsx#L15-L18):
```tsx
vi.spyOn(defaultStore, 'sync')
.mockImplementationOnce(() => Promise.resolve()
// Just enough microtasks for this setup.
// Comment this out to add a warning.
.then(() => void 0)
.then(() => void 0)
)
```