From 4d8a8c5ab7ebe9a67029a2675a77bd93dc2d4b59 Mon Sep 17 00:00:00 2001 From: imprashast Date: Thu, 1 Feb 2024 15:14:22 +0100 Subject: [PATCH] chore: add coverage report --- .gitignore | 1 + package.json | 3 +- pnpm-lock.yaml | 34 +++++++++++++++++++++ vite.config.js | 80 +++++++++++++++++++++++++++++++------------------- 4 files changed, 87 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 7ff23e0c..7233083e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dist/ .vscode settings.json storybook-static/ +coverage/ diff --git a/package.json b/package.json index d4760fff..de1548ca 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "postsite": "cd dev/dist && cp index.html 200.html && cp index.html 404.html", "site": "vite build dev --config ./vite.config.js", "storybook": "storybook dev -p 6006", - "test": "vitest run", + "test": "vitest run --coverage", "watch": "vitest watch" }, "keywords": [], @@ -64,6 +64,7 @@ "@storybook/vue3": "^7.6.10", "@storybook/vue3-vite": "^7.6.10", "@vitejs/plugin-vue": "^5.0.0", + "@vitest/coverage-v8": "^1.2.2", "@vue/compiler-sfc": "^3.4.14", "@vue/test-utils": "^2.4.1", "cleave-lite": "^1.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5d167ccc..881e56eb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -103,6 +103,9 @@ devDependencies: '@vitejs/plugin-vue': specifier: ^5.0.0 version: 5.0.3(vite@5.0.11)(vue@3.4.14) + '@vitest/coverage-v8': + specifier: ^1.2.2 + version: 1.2.2(vitest@1.2.1) '@vue/compiler-sfc': specifier: ^3.4.14 version: 3.4.14 @@ -5244,6 +5247,29 @@ packages: vue: 3.4.14(typescript@5.1.6) dev: true + /@vitest/coverage-v8@1.2.2(vitest@1.2.1): + resolution: {integrity: sha512-IHyKnDz18SFclIEEAHb9Y4Uxx0sPKC2VO1kdDCs1BF6Ip4S8rQprs971zIsooLUn7Afs71GRxWMWpkCGZpRMhw==} + peerDependencies: + vitest: ^1.0.0 + dependencies: + '@ampproject/remapping': 2.2.1 + '@bcoe/v8-coverage': 0.2.3 + debug: 4.3.4 + istanbul-lib-coverage: 3.2.2 + istanbul-lib-report: 3.0.1 + istanbul-lib-source-maps: 4.0.1 + istanbul-reports: 3.1.6 + magic-string: 0.30.5 + magicast: 0.3.3 + picocolors: 1.0.0 + std-env: 3.7.0 + test-exclude: 6.0.0 + v8-to-istanbul: 9.2.0 + vitest: 1.2.1(@types/node@20.4.2)(happy-dom@13.1.4) + transitivePeerDependencies: + - supports-color + dev: true + /@vitest/expect@0.34.7: resolution: {integrity: sha512-G9iEtwrD6ZQ4MVHZufif9Iqz3eLtuwBBNx971fNAGPaugM7ftAWjQN+ob2zWhtzURp8RK3zGXOxVb01mFo3zAQ==} dependencies: @@ -9978,6 +10004,14 @@ packages: dependencies: '@jridgewell/sourcemap-codec': 1.4.15 + /magicast@0.3.3: + resolution: {integrity: sha512-ZbrP1Qxnpoes8sz47AM0z08U+jW6TyRgZzcWy3Ma3vDhJttwMwAFDMMQFobwdBxByBD46JYmxRzeF7w2+wJEuw==} + dependencies: + '@babel/parser': 7.23.6 + '@babel/types': 7.23.6 + source-map-js: 1.0.2 + dev: true + /make-dir@2.1.0: resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==} engines: {node: '>=6'} diff --git a/vite.config.js b/vite.config.js index 7d44d09e..1b2737fe 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,10 +1,10 @@ -import { defineConfig } from 'vite' -import vue from '@vitejs/plugin-vue' -import { presetWarp } from '@warp-ds/uno' -import uno from 'unocss/vite' -import { MinifyWarpLib } from './.minifier-plugin.js' -import VitEik from 'viteik' -import { classes } from '@warp-ds/css/component-classes/classes'; +import { defineConfig } from "vite"; +import vue from "@vitejs/plugin-vue"; +import { presetWarp } from "@warp-ds/uno"; +import uno from "unocss/vite"; +import { MinifyWarpLib } from "./.minifier-plugin.js"; +import VitEik from "viteik"; +import { classes } from "@warp-ds/css/component-classes/classes"; export default defineConfig((env) => ({ plugins: [ @@ -13,39 +13,59 @@ export default defineConfig((env) => ({ presets: [presetWarp({ skipResets: true })], safelist: classes, }), - env.mode !== 'lib' && VitEik(), + env.mode !== "lib" && VitEik(), MinifyWarpLib(), ], server: { host: "0.0.0.0", port: 3003 }, - test: { environment: 'happy-dom' }, - ...getBuildOpts(env) -})) + test: { + environment: "happy-dom", + include: ["./test/**"], + exclude: ["**.json"], + coverage: { + cleanOnRerun: true, + reporter: ["text"], + exclude: [ + "**.json", + "dev/**", + "storybook-static/**", + ".storybook/**", + "components/**/stories", + ".minifier-plugin.js", + "lingui.config.ts", + ], + }, + }, + ...getBuildOpts(env), +})); function getBuildOpts(env) { - if (env.mode === 'production') return defineConfig({ - build: { target: 'esnext' } - }) - if (env.mode === 'lib') return defineConfig({ - build: { - ...getLibOpts('warp-vue'), - rollupOptions: { external: ['vue'] } - } - }) - if (env.mode === 'eik') return defineConfig({ - build: { - emptyOutDir: false, - ...getLibOpts('warp-vue.eik') - } - }) + if (env.mode === "production") + return defineConfig({ + build: { target: "esnext" }, + }); + if (env.mode === "lib") + return defineConfig({ + build: { + ...getLibOpts("warp-vue"), + rollupOptions: { external: ["vue"] }, + }, + }); + if (env.mode === "eik") + return defineConfig({ + build: { + emptyOutDir: false, + ...getLibOpts("warp-vue.eik"), + }, + }); } function getLibOpts(fileName) { return { sourcemap: true, lib: { - formats: ['es'], - entry: './index.js', - fileName + formats: ["es"], + entry: "./index.js", + fileName, }, - } + }; }