From d0ecab5e8879391a196f48d6d735610cd0165ef8 Mon Sep 17 00:00:00 2001 From: Zaid Ahmad <109442753+zaidahmad16@users.noreply.github.com> Date: Mon, 22 Jun 2026 21:03:32 -0400 Subject: [PATCH] feat: Add Vitest coverage reporting --- .gitignore | 3 +- eslint.config.js | 2 +- package.json | 2 + pnpm-lock.yaml | 170 ++++++++++++++++++++++++++++++++++++++++++++++- vite.config.ts | 11 +++ 5 files changed, 184 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index fc6b291..4e9e56a 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ dist-ssr *.sw? # Output -scripts/output/*.json \ No newline at end of file +scripts/output/*.json +coverage/ \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js index 973e273..3635b64 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -6,7 +6,7 @@ import tseslint from 'typescript-eslint'; import { defineConfig, globalIgnores } from 'eslint/config'; export default defineConfig([ - globalIgnores(['dist']), + globalIgnores(['dist', 'coverage']), { files: ['**/*.{ts,tsx}'], extends: [ diff --git a/package.json b/package.json index f6dea1b..37d2749 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "build": "tsc -b && vite build", "preview": "vite preview", "test": "vitest run", + "test:coverage": "vitest run --coverage", "typecheck": "tsc -b", "lint": "eslint .", "format": "prettier --write .", @@ -33,6 +34,7 @@ "@types/react": "^19.2.14", "@types/react-dom": "^19.2.3", "@vitejs/plugin-react": "^6.0.1", + "@vitest/coverage-v8": "^4.1.8", "cheerio": "^1.2.0", "eslint": "^10.3.0", "eslint-config-prettier": "^10.1.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 78c74f2..88fed23 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -53,6 +53,9 @@ importers: '@vitejs/plugin-react': specifier: ^6.0.1 version: 6.0.2(vite@8.0.14(@types/node@24.12.4)(jiti@2.7.0)) + '@vitest/coverage-v8': + specifier: ^4.1.8 + version: 4.1.8(vitest@4.1.7) cheerio: specifier: ^1.2.0 version: 1.2.0 @@ -91,7 +94,7 @@ importers: version: 8.0.14(@types/node@24.12.4)(jiti@2.7.0) vitest: specifier: ^4.1.7 - version: 4.1.7(@types/node@24.12.4)(jsdom@29.1.1)(vite@8.0.14(@types/node@24.12.4)(jiti@2.7.0)) + version: 4.1.7(@types/node@24.12.4)(@vitest/coverage-v8@4.1.8)(jsdom@29.1.1)(vite@8.0.14(@types/node@24.12.4)(jiti@2.7.0)) packages: '@adobe/css-tools@4.5.0': @@ -249,6 +252,13 @@ packages: } engines: { node: '>=6.9.0' } + '@bcoe/v8-coverage@1.0.2': + resolution: + { + integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==, + } + engines: { node: '>=18' } + '@bramus/specificity@2.4.2': resolution: { @@ -1031,6 +1041,18 @@ packages: babel-plugin-react-compiler: optional: true + '@vitest/coverage-v8@4.1.8': + resolution: + { + integrity: sha512-lt3kovsyHwYe00wq4D1ti0Z974fWj4NLp6siqiyEufUpyFwK9Yhi7rBhac9JL5aA0zoMrJqc4vYPZRUnI7l7nw==, + } + peerDependencies: + '@vitest/browser': 4.1.8 + vitest: 4.1.8 + peerDependenciesMeta: + '@vitest/browser': + optional: true + '@vitest/expect@4.1.7': resolution: { @@ -1057,6 +1079,12 @@ packages: integrity: sha512-umgCarTOYQWIaDMvGDRZij+6b9oVeLIyJzfN+AS88e0ZOU3QTgNNSTtjQOpcvWr3np1N0j4WgZj+sb3oYBDscw==, } + '@vitest/pretty-format@4.1.8': + resolution: + { + integrity: sha512-9GasEBxpZ1VYIpqHf/0+YGg121uSNwCKOJqIrTwWP/TB7DmFCiaBpNl3aPZzoLWfWkuqhbH8vJIVobZkvdo2cA==, + } + '@vitest/runner@4.1.7': resolution: { @@ -1081,6 +1109,12 @@ packages: integrity: sha512-T532WBu791cBxJlCl6SO+J14l81DQx6uQHm1bQbmCDY7nqlEIgkza/UFnSBNaUtSf41unldDFjdOBYEQC4b5Hw==, } + '@vitest/utils@4.1.8': + resolution: + { + integrity: sha512-uOJamYALNhfJ6iolExyQM40yIQwDqYnkKtQ5VCiSe17E33H0aQ/u+1GlRuz4LZBk6Mm3sg90G9hEbmEt37C1Zg==, + } + '@xyflow/react@12.10.2': resolution: { @@ -1152,6 +1186,12 @@ packages: } engines: { node: '>=12' } + ast-v8-to-istanbul@1.0.4: + resolution: + { + integrity: sha512-0bC0/4bTSrnwdhU3IsZDwEdojvuPrSg59OYZfKsLRtJZ0u8VBx9DebfqqG8bRdCC0I7vjgxmPi41P0lpkhJHtA==, + } + balanced-match@4.0.4: resolution: { @@ -1692,6 +1732,13 @@ packages: integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==, } + has-flag@4.0.0: + resolution: + { + integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==, + } + engines: { node: '>=8' } + hermes-estree@0.25.1: resolution: { @@ -1711,6 +1758,12 @@ packages: } engines: { node: ^20.19.0 || ^22.12.0 || >=24.0.0 } + html-escaper@2.0.2: + resolution: + { + integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==, + } + htmlparser2@10.1.0: resolution: { @@ -1778,6 +1831,27 @@ packages: integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==, } + istanbul-lib-coverage@3.2.2: + resolution: + { + integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==, + } + engines: { node: '>=8' } + + istanbul-lib-report@3.0.1: + resolution: + { + integrity: sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==, + } + engines: { node: '>=10' } + + istanbul-reports@3.2.0: + resolution: + { + integrity: sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==, + } + engines: { node: '>=8' } + jiti@2.7.0: resolution: { @@ -1785,6 +1859,12 @@ packages: } hasBin: true + js-tokens@10.0.0: + resolution: + { + integrity: sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==, + } + js-tokens@4.0.0: resolution: { @@ -1993,6 +2073,19 @@ packages: integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==, } + magicast@0.5.3: + resolution: + { + integrity: sha512-pVKE4UdSQ7DvHzivsCIFx2BJn1mHG6KsyrFcaxFx6tONdneEuThrDx0Cj3AMg58KyN4pzYT+LHOotxDQDjNvkw==, + } + + make-dir@4.0.0: + resolution: + { + integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==, + } + engines: { node: '>=10' } + mdn-data@2.27.1: resolution: { @@ -2318,6 +2411,13 @@ packages: } engines: { node: '>=8' } + supports-color@7.2.0: + resolution: + { + integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==, + } + engines: { node: '>=8' } + symbol-tree@3.2.4: resolution: { @@ -2828,6 +2928,8 @@ snapshots: '@babel/helper-string-parser': 7.29.7 '@babel/helper-validator-identifier': 7.29.7 + '@bcoe/v8-coverage@1.0.2': {} + '@bramus/specificity@2.4.2': dependencies: css-tree: 3.2.1 @@ -3262,6 +3364,20 @@ snapshots: '@rolldown/pluginutils': 1.0.1 vite: 8.0.14(@types/node@24.12.4)(jiti@2.7.0) + '@vitest/coverage-v8@4.1.8(vitest@4.1.7)': + dependencies: + '@bcoe/v8-coverage': 1.0.2 + '@vitest/utils': 4.1.8 + ast-v8-to-istanbul: 1.0.4 + istanbul-lib-coverage: 3.2.2 + istanbul-lib-report: 3.0.1 + istanbul-reports: 3.2.0 + magicast: 0.5.3 + obug: 2.1.1 + std-env: 4.1.0 + tinyrainbow: 3.1.0 + vitest: 4.1.7(@types/node@24.12.4)(@vitest/coverage-v8@4.1.8)(jsdom@29.1.1)(vite@8.0.14(@types/node@24.12.4)(jiti@2.7.0)) + '@vitest/expect@4.1.7': dependencies: '@standard-schema/spec': 1.1.0 @@ -3283,6 +3399,10 @@ snapshots: dependencies: tinyrainbow: 3.1.0 + '@vitest/pretty-format@4.1.8': + dependencies: + tinyrainbow: 3.1.0 + '@vitest/runner@4.1.7': dependencies: '@vitest/utils': 4.1.7 @@ -3303,6 +3423,12 @@ snapshots: convert-source-map: 2.0.0 tinyrainbow: 3.1.0 + '@vitest/utils@4.1.8': + dependencies: + '@vitest/pretty-format': 4.1.8 + convert-source-map: 2.0.0 + tinyrainbow: 3.1.0 + '@xyflow/react@12.10.2(@types/react@19.2.15)(react-dom@19.2.6(react@19.2.6))(react@19.2.6)': dependencies: '@xyflow/system': 0.0.76 @@ -3351,6 +3477,12 @@ snapshots: assertion-error@2.0.1: {} + ast-v8-to-istanbul@1.0.4: + dependencies: + '@jridgewell/trace-mapping': 0.3.31 + estree-walker: 3.0.3 + js-tokens: 10.0.0 + balanced-match@4.0.4: {} baseline-browser-mapping@2.10.32: {} @@ -3664,6 +3796,8 @@ snapshots: graceful-fs@4.2.11: {} + has-flag@4.0.0: {} + hermes-estree@0.25.1: {} hermes-parser@0.25.1: @@ -3676,6 +3810,8 @@ snapshots: transitivePeerDependencies: - '@noble/hashes' + html-escaper@2.0.2: {} + htmlparser2@10.1.0: dependencies: domelementtype: 2.3.0 @@ -3705,8 +3841,23 @@ snapshots: isexe@2.0.0: {} + istanbul-lib-coverage@3.2.2: {} + + istanbul-lib-report@3.0.1: + dependencies: + istanbul-lib-coverage: 3.2.2 + make-dir: 4.0.0 + supports-color: 7.2.0 + + istanbul-reports@3.2.0: + dependencies: + html-escaper: 2.0.2 + istanbul-lib-report: 3.0.1 + jiti@2.7.0: {} + js-tokens@10.0.0: {} + js-tokens@4.0.0: {} jsdom@29.1.1: @@ -3819,6 +3970,16 @@ snapshots: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 + magicast@0.5.3: + dependencies: + '@babel/parser': 7.29.7 + '@babel/types': 7.29.7 + source-map-js: 1.2.1 + + make-dir@4.0.0: + dependencies: + semver: 7.8.1 + mdn-data@2.27.1: {} min-indent@1.0.1: {} @@ -3986,6 +4147,10 @@ snapshots: dependencies: min-indent: 1.0.1 + supports-color@7.2.0: + dependencies: + has-flag: 4.0.0 + symbol-tree@3.2.4: {} tailwindcss@4.3.0: {} @@ -4071,7 +4236,7 @@ snapshots: fsevents: 2.3.3 jiti: 2.7.0 - vitest@4.1.7(@types/node@24.12.4)(jsdom@29.1.1)(vite@8.0.14(@types/node@24.12.4)(jiti@2.7.0)): + vitest@4.1.7(@types/node@24.12.4)(@vitest/coverage-v8@4.1.8)(jsdom@29.1.1)(vite@8.0.14(@types/node@24.12.4)(jiti@2.7.0)): dependencies: '@vitest/expect': 4.1.7 '@vitest/mocker': 4.1.7(vite@8.0.14(@types/node@24.12.4)(jiti@2.7.0)) @@ -4095,6 +4260,7 @@ snapshots: why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 24.12.4 + '@vitest/coverage-v8': 4.1.8(vitest@4.1.7) jsdom: 29.1.1 transitivePeerDependencies: - msw diff --git a/vite.config.ts b/vite.config.ts index e03c6e8..9f5d337 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,5 +15,16 @@ export default defineConfig({ environment: 'jsdom', setupFiles: ['./src/test/setup.ts'], passWithNoTests: true, + coverage: { + provider: 'v8', + reporter: ['text', 'html'], + exclude: [ + '*.config.*', + '**/*.test.ts', + 'src/types/**', + 'src/test/**', + 'src/main.tsx', + ], + }, }, });