https://github.com/learning-zone/react-unit-testing
React Unit Testing
https://github.com/learning-zone/react-unit-testing
api-testing component-testing jest mock-testing react react-testing-library testing
Last synced: 7 months ago
JSON representation
React Unit Testing
- Host: GitHub
- URL: https://github.com/learning-zone/react-unit-testing
- Owner: learning-zone
- License: mit
- Created: 2022-08-03T04:27:16.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-11T17:09:00.000Z (over 2 years ago)
- Last Synced: 2025-06-01T15:49:57.971Z (8 months ago)
- Topics: api-testing, component-testing, jest, mock-testing, react, react-testing-library, testing
- Language: JavaScript
- Homepage:
- Size: 557 KB
- Stars: 31
- Watchers: 3
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# React Unit Testing using Jest
> *Click ★ if you like the project. Your contributions are heartily ♡ welcome.*
## Installation
```bash
# Package Installation
npm install
# Run the Project
npm start
# Project Test
npm test
# Generate Code Coverage Report
npm run test -- --coverage --watchAll=false
```
## Project Covers
- Component Testing
- Props Testing
- Snapshot Testing
- Event Testing
- Mocking function
- Rest API Testing
## Folder Structure
```js
+ src
+ components
+ Events
+ __snapshots__
- Events.js
- Events.test.js
+ Header
- Header.js
- Header.test.js
+ Props
- Props.js
- Props.test.js
+ RestAPI
- RestAPI.js
- RestAPI.test.js
+ __mocks__
- axios.js
```
## Code Coverage Report
```js
|File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
|------------------------|----------|----------|----------|----------|-------------------|
|All files | 88.89 | 0 | 75 | 88.24 | |
| src | 100 | 100 | 100 | 100 | |
| App.js | 100 | 100 | 100 | 100 | |
| src/Components/Events | 50 | 0 | 33.33 | 50 | |
| Events.js | 50 | 0 | 33.33 | 50 | 14,16 |
| src/Components/Header | 100 | 100 | 100 | 100 | |
| Header.js | 100 | 100 | 100 | 100 | |
| src/Components/Props | 100 | 100 | 100 | 100 | |
| Props.js | 100 | 100 | 100 | 100 | |
| src/Components/RestAPI | 100 | 100 | 80 | 100 | |
| RestAPI.js | 100 | 100 | 80 | 100 | |
|------------------------|----------|----------|----------|----------|-------------------|
```
## Technology
- [React](https://create-react-app.dev/docs/getting-started/)
- [Jest](https://jestjs.io/docs/en/getting-started.html)
- [Material-UI](https://material-ui.com/getting-started/installation/)
- [Axios](https://github.com/axios/axios)
- [React Testing Library](https://reactjs.org/docs/testing-recipes.html)