From b147c077d9b177ca8e199f01d1dfee47c3b8ddb5 Mon Sep 17 00:00:00 2001 From: Jorge Vargas Date: Wed, 15 May 2024 10:13:16 -0500 Subject: [PATCH] test: create vitest workspace --- .gitignore | 1 + .../{vitest.config.ts => vitest.config.mts} | 0 libs/backend/package.json | 5 +- .../backend/vitest.config.ts | 0 libs/frontend/package.json | 11 +- libs/frontend/vitest.config.mts | 12 ++ libs/shared/package.json | 3 +- package.json | 3 - pnpm-lock.yaml | 148 ++++++++++++++++-- vitest.workspace.js | 7 + 10 files changed, 163 insertions(+), 27 deletions(-) rename apps/nextjs/{vitest.config.ts => vitest.config.mts} (100%) rename vitest.config.ts => libs/backend/vitest.config.ts (100%) create mode 100644 libs/frontend/vitest.config.mts create mode 100644 vitest.workspace.js diff --git a/.gitignore b/.gitignore index 88ca10c..478fd43 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ node_modules /test-results/ /playwright-report/ /playwright/.cache/ +vitest.config.mts.timestamp* \ No newline at end of file diff --git a/apps/nextjs/vitest.config.ts b/apps/nextjs/vitest.config.mts similarity index 100% rename from apps/nextjs/vitest.config.ts rename to apps/nextjs/vitest.config.mts diff --git a/libs/backend/package.json b/libs/backend/package.json index db131e5..d961f2f 100644 --- a/libs/backend/package.json +++ b/libs/backend/package.json @@ -4,7 +4,7 @@ "description": "", "scripts": { "lint": "eslint .", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "vitest" }, "keywords": [], "author": "", @@ -22,6 +22,7 @@ "@eslint/js": "^9.2.0", "eslint": "8.57.0", "globals": "^15.2.0", - "typescript-eslint": "^7.9.0" + "typescript-eslint": "^7.9.0", + "vitest": "1.6.0" } } diff --git a/vitest.config.ts b/libs/backend/vitest.config.ts similarity index 100% rename from vitest.config.ts rename to libs/backend/vitest.config.ts diff --git a/libs/frontend/package.json b/libs/frontend/package.json index 32af481..c542a1e 100644 --- a/libs/frontend/package.json +++ b/libs/frontend/package.json @@ -4,7 +4,7 @@ "description": "", "scripts": { "lint": "eslint .", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "vitest" }, "keywords": [], "author": "", @@ -25,13 +25,14 @@ "react-use": "17.4.0" }, "devDependencies": { - "@eslint/js": "^9.2.0", - "@testing-library/react": "13.4.0", + "@eslint/js": "9.2.0", + "@testing-library/react": "15.0.7", + "@vitejs/plugin-react": "4.2.1", "eslint": "8.57.0", - "eslint-plugin-react": "^7.34.1", + "eslint-plugin-react": "7.34.1", "globals": "^15.2.0", "react-test-renderer": "18.2.0", - "typescript-eslint": "^7.9.0", + "typescript-eslint": "7.9.0", "vitest": "1.6.0" } } diff --git a/libs/frontend/vitest.config.mts b/libs/frontend/vitest.config.mts new file mode 100644 index 0000000..431339e --- /dev/null +++ b/libs/frontend/vitest.config.mts @@ -0,0 +1,12 @@ +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vitest/config'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], + test: { + environment: 'jsdom', + include: ['**/*.(test|spec).(ts|tsx)'], + exclude: ['**/node_modules/**', '**/*.e2e-spec.ts'], + }, +}); diff --git a/libs/shared/package.json b/libs/shared/package.json index 4116317..644ed16 100644 --- a/libs/shared/package.json +++ b/libs/shared/package.json @@ -4,8 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "lint": "eslint .", - "test": "echo \"Error: no test specified\" && exit 1" + "lint": "eslint ." }, "keywords": [], "author": "", diff --git a/package.json b/package.json index 111590f..ae9ba49 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,7 @@ }, "devDependencies": { "@playwright/test": "1.44.0", - "@testing-library/react": "13.4.0", "@types/node": "18.7.16", - "autoprefixer": "10.4.9", - "eslint": "8.57.0", "typescript": "5.4.5", "vitest": "1.6.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1b1c1f5..6d1ff5f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,18 +11,9 @@ importers: '@playwright/test': specifier: 1.44.0 version: 1.44.0 - '@testing-library/react': - specifier: 13.4.0 - version: 13.4.0(react-dom@18.2.0)(react@18.2.0) '@types/node': specifier: 18.7.16 version: 18.7.16 - autoprefixer: - specifier: 10.4.9 - version: 10.4.9(postcss@8.4.38) - eslint: - specifier: 8.57.0 - version: 8.57.0 typescript: specifier: 5.4.5 version: 5.4.5 @@ -128,7 +119,7 @@ importers: version: 4.9.1 next: specifier: 14.2.3 - version: 14.2.3(@babel/core@7.24.5)(@playwright/test@1.44.0)(react-dom@18.2.0)(react@18.2.0)(sass@1.54.9) + version: 14.2.3(@playwright/test@1.44.0)(react-dom@18.2.0)(react@18.2.0) sharp: specifier: 0.33.3 version: 0.33.3 @@ -145,6 +136,9 @@ importers: typescript-eslint: specifier: ^7.9.0 version: 7.9.0(eslint@8.57.0)(typescript@5.4.5) + vitest: + specifier: 1.6.0 + version: 1.6.0(@types/node@18.7.16) libs/frontend: dependencies: @@ -183,16 +177,19 @@ importers: version: 17.4.0(react-dom@18.2.0)(react@18.2.0) devDependencies: '@eslint/js': - specifier: ^9.2.0 + specifier: 9.2.0 version: 9.2.0 '@testing-library/react': - specifier: 13.4.0 - version: 13.4.0(react-dom@18.2.0)(react@18.2.0) + specifier: 15.0.7 + version: 15.0.7(@types/react@18.0.19)(react-dom@18.2.0)(react@18.2.0) + '@vitejs/plugin-react': + specifier: 4.2.1 + version: 4.2.1(vite@5.2.11) eslint: specifier: 8.57.0 version: 8.57.0 eslint-plugin-react: - specifier: ^7.34.1 + specifier: 7.34.1 version: 7.34.1(eslint@8.57.0) globals: specifier: ^15.2.0 @@ -201,7 +198,7 @@ importers: specifier: 18.2.0 version: 18.2.0(react@18.2.0) typescript-eslint: - specifier: ^7.9.0 + specifier: 7.9.0 version: 7.9.0(eslint@8.57.0)(typescript@5.4.5) vitest: specifier: 1.6.0 @@ -1414,6 +1411,20 @@ packages: use-sync-external-store: 1.2.2(react@18.2.0) dev: false + /@testing-library/dom@10.1.0: + resolution: {integrity: sha512-wdsYKy5zupPyLCW2Je5DLHSxSfbIp6h80WoHOQc+RPtmPGA52O9x5MJEkv92Sjonpq+poOAtUKhh1kBGAXBrNA==} + engines: {node: '>=18'} + dependencies: + '@babel/code-frame': 7.24.2 + '@babel/runtime': 7.24.5 + '@types/aria-query': 5.0.4 + aria-query: 5.3.0 + chalk: 4.1.2 + dom-accessibility-api: 0.5.16 + lz-string: 1.5.0 + pretty-format: 27.5.1 + dev: true + /@testing-library/dom@8.20.1: resolution: {integrity: sha512-/DiOQ5xBxgdYRC8LNk7U+RWat0S3qRLeIw3ZIkMQ9kkVlRmwD/Eg8k8CqIpD6GW7u20JIUOfMKbxtiLutpjQ4g==} engines: {node: '>=12'} @@ -1442,6 +1453,25 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: true + /@testing-library/react@15.0.7(@types/react@18.0.19)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-cg0RvEdD1TIhhkm1IeYMQxrzy0MtUNfa3minv4MjbgcYzJAZ7yD0i0lwoPOTPr+INtiXFezt2o8xMSnyHhEn2Q==} + engines: {node: '>=18'} + peerDependencies: + '@types/react': ^18.0.0 + react: ^18.0.0 + react-dom: ^18.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + dependencies: + '@babel/runtime': 7.24.5 + '@testing-library/dom': 10.1.0 + '@types/react': 18.0.19 + '@types/react-dom': 18.0.6 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: true + /@tootallnate/once@2.0.0: resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} engines: {node: '>= 10'} @@ -1451,6 +1481,35 @@ packages: resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==} dev: true + /@types/babel__core@7.20.5: + resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} + dependencies: + '@babel/parser': 7.24.5 + '@babel/types': 7.24.5 + '@types/babel__generator': 7.6.8 + '@types/babel__template': 7.4.4 + '@types/babel__traverse': 7.20.5 + dev: true + + /@types/babel__generator@7.6.8: + resolution: {integrity: sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==} + dependencies: + '@babel/types': 7.24.5 + dev: true + + /@types/babel__template@7.4.4: + resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==} + dependencies: + '@babel/parser': 7.24.5 + '@babel/types': 7.24.5 + dev: true + + /@types/babel__traverse@7.20.5: + resolution: {integrity: sha512-WXCyOcRtH37HAUkpXhUduaxdm82b4GSlyTqajXviN4EfiuPgNYR109xMCKvpl6zPIpua0DGlMEDCq+g8EdoheQ==} + dependencies: + '@babel/types': 7.24.5 + dev: true + /@types/estree@1.0.5: resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} dev: true @@ -1739,6 +1798,22 @@ packages: - supports-color dev: true + /@vitejs/plugin-react@4.2.1(vite@5.2.11): + resolution: {integrity: sha512-oojO9IDc4nCUUi8qIR11KoQm0XFFLIwsRBwHRR4d/88IWghn1y6ckz/bJ8GHDCsYEJee8mDzqtJxh15/cisJNQ==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + vite: ^4.2.0 || ^5.0.0 + dependencies: + '@babel/core': 7.24.5 + '@babel/plugin-transform-react-jsx-self': 7.24.5(@babel/core@7.24.5) + '@babel/plugin-transform-react-jsx-source': 7.24.1(@babel/core@7.24.5) + '@types/babel__core': 7.20.5 + react-refresh: 0.14.2 + vite: 5.2.11(@types/node@18.7.16) + transitivePeerDependencies: + - supports-color + dev: true + /@vitest/expect@1.6.0: resolution: {integrity: sha512-ixEvFVQjycy/oNgHjqsL6AZCDduC+tflRluaHIzKIsdbzkLn2U/iBnVeJwB6HsIjQBdfMR8Z0tRxKUsvFJEeWQ==} dependencies: @@ -4373,6 +4448,49 @@ packages: - babel-plugin-macros dev: false + /next@14.2.3(@playwright/test@1.44.0)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-dowFkFTR8v79NPJO4QsBUtxv0g9BrS/phluVpMAt2ku7H+cbcBJlopXjkWlwxrk/xGqMemr7JkGPGemPrLLX7A==} + engines: {node: '>=18.17.0'} + hasBin: true + peerDependencies: + '@opentelemetry/api': ^1.1.0 + '@playwright/test': ^1.41.2 + react: ^18.2.0 + react-dom: ^18.2.0 + sass: ^1.3.0 + peerDependenciesMeta: + '@opentelemetry/api': + optional: true + '@playwright/test': + optional: true + sass: + optional: true + dependencies: + '@next/env': 14.2.3 + '@playwright/test': 1.44.0 + '@swc/helpers': 0.5.5 + busboy: 1.6.0 + caniuse-lite: 1.0.30001618 + graceful-fs: 4.2.11 + postcss: 8.4.31 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + styled-jsx: 5.1.1(@babel/core@7.24.5)(react@18.2.0) + optionalDependencies: + '@next/swc-darwin-arm64': 14.2.3 + '@next/swc-darwin-x64': 14.2.3 + '@next/swc-linux-arm64-gnu': 14.2.3 + '@next/swc-linux-arm64-musl': 14.2.3 + '@next/swc-linux-x64-gnu': 14.2.3 + '@next/swc-linux-x64-musl': 14.2.3 + '@next/swc-win32-arm64-msvc': 14.2.3 + '@next/swc-win32-ia32-msvc': 14.2.3 + '@next/swc-win32-x64-msvc': 14.2.3 + transitivePeerDependencies: + - '@babel/core' + - babel-plugin-macros + dev: false + /node-releases@2.0.14: resolution: {integrity: sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==} diff --git a/vitest.workspace.js b/vitest.workspace.js new file mode 100644 index 0000000..eabb504 --- /dev/null +++ b/vitest.workspace.js @@ -0,0 +1,7 @@ +import { defineWorkspace } from 'vitest/config'; + +export default defineWorkspace([ + './apps/nextjs/vitest.config.mts', + './libs/frontend/vitest.config.mts', + './libs/backend/vitest.config.mts', +]);