Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created Unit Test for Frontend Buildcheck Workflow #1148

Merged
merged 19 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,19 @@
| | | |- 📜 about.tsx
| | | |- 📜 wiki.tsx
| | | |- 📜 _document.tsx
| | |- 📂 __tests__:
| | | |- 📂 common:
| | | | |- 📂 components:
| | | | | |- 📜 TitleText.test.tsx
| | |- 📜 constants.ts
| | |- 📜 iris.csv : Sample CSV data
| | |- 📜 GlobalStyle.ts
| | |- 📜 next-env.d.ts
| |- 📜 .eslintignore
| |- 📜 tsconfig.json
| |- 📜 .eslintrc.json
| |- 📜 jest.config.ts
| |- 📜 pnpm-lock.yaml
| |- 📜 jest.config.js
| |- 📜 package.json
| |- 📜 next.config.js
| |- 📜 next-env.d.ts
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3

- name: Install pnpm
run: npm install -g pnpm
run: npm install -g pnpm
working-directory: ./frontend

- name: Install
run: pnpm install --frozen-lockfile
working-directory: ./frontend

- name: Test
run: echo "pnpm run test should be here"
run: pnpm test
working-directory: ./frontend


4 changes: 0 additions & 4 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,4 @@ jobs:
run: pnpm lint
working-directory: ./frontend

- name: Run depcheck
run: npx depcheck --ignore-bin-package
working-directory: ./frontend

# future: add yarn build once build errors are resolved
6 changes: 0 additions & 6 deletions frontend/jest.config.js

This file was deleted.

22 changes: 22 additions & 0 deletions frontend/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Config } from 'jest'
import nextJest from 'next/jest.js'

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})

// Add any custom config to be passed to Jest
const config: Config = {
preset: "ts-jest",
transform: {
"^.+\.tsx?$": "babel-jest",
},
coverageProvider: 'v8',
testEnvironment: 'jsdom',
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
}

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default createJestConfig(config)
10 changes: 9 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"scripts": {
"preinstall": "npx only-allow pnpm",
"lint": "next lint",
"start": "next dev"
"start": "next dev",
"test": "jest",
"test:watch": "jest --watch"
},
"keywords": [],
"author": "",
Expand Down Expand Up @@ -56,13 +58,19 @@
},
"devDependencies": {
"@next/eslint-plugin-next": "^14.0.1",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"depcheck": "^1.4.7",
"eslint": "^8.52.0",
"eslint-plugin-react": "^7.33.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "3.2.2",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.2.2"
}
}
Loading
Loading