Skip to content

Commit ab04ada

Browse files
committed
chore(test setup):setup test with jest library
-ensure jest is configured to test components -ensure all command needed to run test are provided in readMe file [Delivers #187419110]
1 parent 12b68b9 commit ab04ada

File tree

8 files changed

+5488
-1657
lines changed

8 files changed

+5488
-1657
lines changed

.github/workflows/main.yml renamed to .github/workflows/deploy.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ jobs:
3232
run: npm install
3333

3434
- name: Running test
35-
run: npm run test
36-
35+
run: npm run test --coverage
36+
3737
- name: Build application
3838
run: npm run build
3939

4040
- name: Upload coverage reports to Codecov
4141
uses: codecov/[email protected]
4242
with:
43-
token: ${{ secrets.CODECOV_TOKEN }}
43+
token: ${{ secrets.CODECOV_TOKEN }}

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
The front-end of Eagle E-commerce utilizes React for a modern, user-friendly interface, while Node.js powers its backend, ensuring a seamless shopping experience
44

5+
[![Maintainability](https://api.codeclimate.com/v1/badges/81fa30232b27b1482f4f/maintainability)](https://codeclimate.com/github/atlp-rwanda/eagles-ec-fe/maintainability)
6+
![Github Actions](https://github.com/atlp-rwanda/eagles-ec-fe/actions/workflows/deploy.yml/badge.svg)
7+
[![codecov](https://codecov.io/gh/atlp-rwanda/eagles-ec-fe/graph/badge.svg?token=MZAXZNVDXC)](https://codecov.io/gh/atlp-rwanda/eagles-ec-fe)
8+
59
## Tech Stack
610

711
This project was built using the PERN (PostgreSQL, Express.js, React.js, Node.js) stack, additionally with Vite and Typescript.
@@ -26,3 +30,18 @@ npm install
2630
```bash
2731
npm run dev
2832
```
33+
## How to run test
34+
35+
1. **Run unit test:**
36+
```bash
37+
npm run test
38+
```
39+
2. **Tun test in watch mode
40+
```bash
41+
npm run test:watch
42+
```
43+
3. **Generate test coverage
44+
```bash
45+
npm run test:coverage
46+
```
47+
Write your test by creating a file with .test.tsx extetion under __test__ directory.

jest.config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
preset: 'ts-jest',
3+
testEnvironment: 'jest-environment-jsdom',
4+
transform: {
5+
"^.+\\.tsx?$": "ts-jest"
6+
},
7+
moduleNameMapper: {
8+
'\\.(gif|ttf|eot|svg|png)$': '<rootDir>/test/__ mocks __/fileMock.js',
9+
},
10+
}

0 commit comments

Comments
 (0)