Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julienbrg committed Oct 14, 2024
1 parent b185c1f commit 835528b
Show file tree
Hide file tree
Showing 8 changed files with 2,814 additions and 38 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run Tests

on:
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Run tests
run: pnpm test
18 changes: 18 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Config } from 'jest'
import nextJest from 'next/jest'

const createJestConfig = nextJest({
dir: './',
})

const customJestConfig: Config = {
preset: 'ts-jest',
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
testEnvironment: 'jest-environment-jsdom',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
}

export default createJestConfig(customJestConfig)
1 change: 1 addition & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom'
21 changes: 16 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"test": "jest",
"test:watch": "jest --watch"
},
"dependencies": {
"@chakra-ui/icons": "^2.1.1",
Expand All @@ -15,11 +17,11 @@
"@coinbase/wallet-sdk": "^4.1.0",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@web3modal/ethers": "^5.1.9",
"@types/node": "22.5.2",
"@types/react": "18.3.5",
"@types/react-dom": "18.3.0",
"@web3modal/ethers": "^5.1.9",
"autoprefixer": "10.4.20",
"eslint": "8.57.1",
"eslint-config-next": "14.2.7",
"ethers": "^6.13.2",
"framer-motion": "^11.7.0",
Expand All @@ -30,7 +32,16 @@
"react-device-detect": "^2.2.3",
"react-dom": "18.3.1",
"react-icons": "^5.3.0",
"typescript": "5.5.4",
"eslint": "8.57.1"
"typescript": "5.5.4"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@types/jest": "^29.5.13",
"@types/node": "22.5.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.2"
}
}
Loading

0 comments on commit 835528b

Please sign in to comment.