Skip to content

Commit 4da0299

Browse files
Set up Jest testing environment and refactor test configurations
1 parent 242f321 commit 4da0299

23 files changed

+17028
-8835
lines changed

.github/workflows/ci-cd.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# .github/workflows/ci.yml
2+
name: CI/CD
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
env:
13+
REACT_APP_AUTH_URL=${{ secrets.REACT_APP_AUTH_URL }}
14+
REACT_APP_COURSE_URL=${{ secrets.REACT_APP_COURSE_URL }}
15+
PORT=${{ secrets.PORT }}
16+
MONGODB_URI=${{ secrets.MONGODB_URI }}
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 16 # Or your desired Node.js version
25+
26+
- name: Install server dependencies
27+
run: cd server && npm install && cd ..
28+
29+
- name: Install client dependencies
30+
run: cd client && npm install && cd ..
31+
32+
- name: Run server tests
33+
run: npm test --prefix server
34+
35+
- name: Run client tests
36+
run: npm test --prefix client
37+
38+
- name: Build Docker images
39+
run: docker compose build

client/jest.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} **/
2+
module.exports = {
3+
preset: 'ts-jest',
4+
testEnvironment: "jsdom",
5+
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'],
6+
moduleDirectories: ['node_modules', 'src'],
7+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
8+
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
9+
transform: {
10+
"^.+.tsx?$": ["ts-jest",{}],
11+
},
12+
};

client/jest.setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@testing-library/jest-dom';

0 commit comments

Comments
 (0)