apps/web: add vitest

This commit is contained in:
vchikalkin 2024-12-10 17:41:38 +03:00
parent 80e54ac294
commit 2b14158d29
7 changed files with 1297 additions and 25 deletions

View File

@ -0,0 +1,8 @@
import Page from './page';
import { render, screen } from '@testing-library/react';
import { expect, test } from 'vitest';
test('Page', () => {
render(<Page />);
expect(screen.getByRole('button', { name: 'Click me' })).toBeDefined();
});

View File

@ -10,32 +10,38 @@
"lint": "next lint", "lint": "next lint",
"check-types": "tsc --noEmit", "check-types": "tsc --noEmit",
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"graphql:codegen": "graphql-codegen --config graphql.config.cjs" "graphql:codegen": "graphql-codegen --config graphql.config.cjs",
"test:unit": "vitest"
}, },
"dependencies": { "dependencies": {
"@apollo/client": "^3.12.2", "@apollo/client": "catalog:",
"@repo/ui": "workspace:*", "@repo/ui": "workspace:*",
"graphql": "^16.9.0", "graphql": "catalog:",
"next": "catalog:", "next": "catalog:",
"react": "catalog:", "react": "catalog:",
"react-dom": "catalog:" "react-dom": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@graphql-codegen/cli": "5.0.3", "@graphql-codegen/cli": "catalog:",
"@graphql-codegen/typed-document-node": "^5.0.12", "@graphql-codegen/typed-document-node": "catalog:",
"@graphql-codegen/typescript": "^4.1.2", "@graphql-codegen/typescript": "catalog:",
"@graphql-codegen/typescript-operations": "^4.4.0", "@graphql-codegen/typescript-operations": "catalog:",
"@graphql-typed-document-node/core": "^3.2.0", "@graphql-typed-document-node/core": "catalog:",
"@repo/eslint-config": "workspace:*", "@repo/eslint-config": "workspace:*",
"@repo/lint-staged-config": "workspace:*", "@repo/lint-staged-config": "workspace:*",
"@repo/typescript-config": "workspace:*", "@repo/typescript-config": "workspace:*",
"@testing-library/react": "catalog:",
"@types/node": "catalog:", "@types/node": "catalog:",
"@types/react": "catalog:", "@types/react": "catalog:",
"@types/react-dom": "catalog:", "@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
"autoprefixer": "catalog:", "autoprefixer": "catalog:",
"jsdom": "catalog:",
"lint-staged": "catalog:", "lint-staged": "catalog:",
"postcss": "catalog:", "postcss": "catalog:",
"tailwindcss": "catalog:", "tailwindcss": "catalog:",
"typescript": "catalog:" "typescript": "catalog:",
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:"
} }
} }

View File

@ -0,0 +1,10 @@
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
export default defineConfig({
plugins: [tsconfigPaths(), react()],
test: {
environment: 'jsdom',
},
});

View File

@ -8,7 +8,8 @@
"format": "prettier --end-of-line lf --write \"**/*.{ts,tsx,md,mjs}\"", "format": "prettier --end-of-line lf --write \"**/*.{ts,tsx,md,mjs}\"",
"prepare": "husky", "prepare": "husky",
"lint-staged": "turbo lint-staged", "lint-staged": "turbo lint-staged",
"graphql:codegen": "turbo graphql:codegen" "graphql:codegen": "turbo graphql:codegen",
"test:unit": "turbo test:unit"
}, },
"devDependencies": { "devDependencies": {
"husky": "catalog:", "husky": "catalog:",

1262
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -2,18 +2,28 @@ packages:
- apps/* - apps/*
- packages/* - packages/*
catalog: catalog:
"@apollo/client": ^3.12.2
"@graphql-codegen/cli": 5.0.3
"@graphql-codegen/typed-document-node": ^5.0.12
"@graphql-codegen/typescript": ^4.1.2
"@graphql-codegen/typescript-operations": ^4.4.0
"@graphql-typed-document-node/core": ^3.2.0
"@radix-ui/react-slot": ^1.1.0 "@radix-ui/react-slot": ^1.1.0
"@testing-library/react": ^16.1.0
"@types/node": ^20 "@types/node": ^20
"@types/react": ^19 "@types/react": ^19
"@types/react-dom": ^19 "@types/react-dom": ^19
"@vchikalkin/eslint-config-awesome": ^2.0.6 "@vchikalkin/eslint-config-awesome": ^2.0.6
"@vitejs/plugin-react": ^4.3.4
autoprefixer: ^10.4.20 autoprefixer: ^10.4.20
class-variance-authority: ^0.7.1 class-variance-authority: ^0.7.1
clsx: ^2.1.1 clsx: ^2.1.1
eslint: ^9.15.0 eslint: ^9.15.0
eslint-plugin-tailwindcss: ^3.17.5 eslint-plugin-tailwindcss: ^3.17.5
eslint-plugin-turbo: ^2.3.0 eslint-plugin-turbo: ^2.3.0
graphql: ^16.9.0
husky: ^9.1.7 husky: ^9.1.7
jsdom: ^25.0.1
lint-staged: ^15.2.10 lint-staged: ^15.2.10
lucide-react: ^0.462.0 lucide-react: ^0.462.0
next: ^15.0.4 next: ^15.0.4
@ -27,3 +37,5 @@ catalog:
tailwindcss-animate: ^1.0.7 tailwindcss-animate: ^1.0.7
turbo: ^2.3.2 turbo: ^2.3.2
typescript: ^5.7 typescript: ^5.7
vite-tsconfig-paths: ^5.1.4
vitest: ^2.1.8

View File

@ -22,6 +22,9 @@
}, },
"graphql:codegen": { "graphql:codegen": {
"cache": false "cache": false
},
"test:unit": {
"cache": false
} }
} }
} }