Skip to content

Commit

Permalink
vitest setup
Browse files Browse the repository at this point in the history
  • Loading branch information
agnlez committed Feb 25, 2025
1 parent bb84890 commit a66d92d
Show file tree
Hide file tree
Showing 7 changed files with 2,049 additions and 13 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/testing-client-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Client Unit Tests
on:
push:
paths:
- '.github/workflows/testing-client-unit-tests.yml'
- 'package.json'
- 'client/**'
workflow_dispatch:
defaults:
run:
working-directory: client
jobs:
client-unit-tests:
name: Client Unit Tests
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Node setup
uses: actions/setup-node@v4
with:
node-version-file: 'client/.nvmrc'

- name: Install dependendencies
run: corepack enable yarn && yarn install

- name: Run unit tests
run: yarn vitest
13 changes: 10 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"cypress": "cypress open",
"cypress:headless": "cypress run --browser chrome",
"test:e2e": "./node_modules/.bin/cypress run --headless --browser chrome",
"test": "start-server-and-test 'yarn build && yarn start' http://localhost:3000/auth/signin 'nyc --reporter nyc-report-lcov-absolute yarn cypress:headless'"
"test": "start-server-and-test 'yarn build && yarn start' http://localhost:3000/auth/signin 'nyc --reporter nyc-report-lcov-absolute yarn cypress:headless'",
"vitest": "vitest"
},
"dependencies": {
"@date-fns/utc": "1.1.1",
Expand Down Expand Up @@ -103,29 +104,35 @@
},
"devDependencies": {
"@t3-oss/env-nextjs": "0.9.2",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/react": "16.2.0",
"@types/chroma-js": "2.1.3",
"@types/d3-format": "3.0.1",
"@types/d3-scale": "4.0.2",
"@types/geojson": "7946.0.14",
"@types/lodash-es": "4.17.6",
"@types/node": "16.11.6",
"@types/node": "20.14.8",
"@types/react": "18.2.79",
"@types/react-dom": "18.2.25",
"@types/uuid": "^9.0.5",
"@typescript-eslint/eslint-plugin": "7.7.1",
"@vitejs/plugin-react": "4.3.4",
"cypress": "13.2.0",
"eslint": "8.57.0",
"eslint-config-next": "14.2.2",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"istanbul-reports": "3.0.0",
"jiti": "1.21.0",
"jsdom": "^26.0.0",
"nyc": "15.1.0",
"nyc-report-lcov-absolute": "1.0.0",
"prettier": "^3.1.1",
"prettier-plugin-tailwindcss": "^0.5.10",
"start-server-and-test": "1.14.0",
"typescript": "5.4.5"
"typescript": "5.4.5",
"vitest": "3.0.7"
},
"packageManager": "yarn@4.1.1"
}
7 changes: 7 additions & 0 deletions client/tests/delete-me.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { expect } from 'vitest';

describe('delete me test', () => {
test('run sample test', () => {
expect(1).toBe(1);
});
});
1 change: 1 addition & 0 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"baseUrl": "./src",
"lib": ["dom", "dom.iterable", "esnext"],
"types": ["vitest/globals", "@testing-library/jest-dom"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
Expand Down
29 changes: 29 additions & 0 deletions client/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import path from 'path';

import react from '@vitejs/plugin-react';
import { defineConfig } from 'vitest/config';

export default defineConfig({
plugins: [react()],
test: {
setupFiles: ['./vitest.setup.ts'],
globals: true,
environment: 'jsdom',
clearMocks: true,
coverage: {
provider: 'v8',
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
lib: path.resolve(__dirname, './src/lib'),
components: path.resolve(__dirname, './src/components'),
store: path.resolve(__dirname, './src/store'),
services: path.resolve(__dirname, './src/services'),
utils: path.resolve(__dirname, './src/utils'),
hooks: path.resolve(__dirname, './src/hooks'),
containers: path.resolve(__dirname, './src/containers'),
},
},
});
1 change: 1 addition & 0 deletions client/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom';
Loading

0 comments on commit a66d92d

Please sign in to comment.