Skip to content

Commit 3f8a19f

Browse files
authored
Merge pull request #1 from atlp-rwanda/187419110-ch-setup-test-ci
#187419110 setup test envirnoment with jest library for unit test and wrking with CI
2 parents f5639c0 + ab04ada commit 3f8a19f

File tree

8 files changed

+5528
-1654
lines changed

8 files changed

+5528
-1654
lines changed

Diff for: .github/workflows/deploy.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
name: Eagle e-commerce CI/CD
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- dev
9+
10+
pull_request:
11+
branches:
12+
- main
13+
- dev
14+
15+
workflow_dispatch:
16+
17+
jobs:
18+
build:
19+
name: Building code
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout the code
24+
uses: actions/checkout@v3
25+
26+
- name: Setup node
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: "20"
30+
31+
- name: Install dependencies
32+
run: npm install
33+
34+
- name: Running test
35+
run: npm run test --coverage
36+
37+
- name: Build application
38+
run: npm run build
39+
40+
- name: Upload coverage reports to Codecov
41+
uses: codecov/[email protected]
42+
with:
43+
token: ${{ secrets.CODECOV_TOKEN }}

Diff for: 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.

Diff for: 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)