From f216ad0e64d95ab91ee90a505cbdf92add97b5d5 Mon Sep 17 00:00:00 2001 From: w2xi <43wangxi@gmail.com> Date: Wed, 31 Jul 2024 23:27:52 +0800 Subject: [PATCH] chore: add `test:ui` script to visualize and interact with tests --- CONTRIBUTING.en-US.md | 1 + CONTRIBUTING.md | 1 + docs/docs/contributing.md | 1 + package.json | 2 + pnpm-lock.yaml | 98 ++++++++++++++++++++++++++++++++++----- 5 files changed, 92 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.en-US.md b/CONTRIBUTING.en-US.md index b45ecd706..56e7661ed 100644 --- a/CONTRIBUTING.en-US.md +++ b/CONTRIBUTING.en-US.md @@ -81,6 +81,7 @@ fighting-design 内部设置了很多的命令,在 [package.json](https://gith | `new` | `pnpm new xxx` | 构建全新组件,生产组件所需要的文件,执行配置文件 [index.ts](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-add-component/index.ts),详情参考 [README.md](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-add-component/README.md) | | `test` | `pnpm test` | 执行单元测试 | | `test:coverage` | `pnpm test:coverage` | 查看单元测试覆盖率,可在终端中生成覆盖率,也可查看项目根目录下的 `coverage/index.html`,参考 [Coverage](https://vitest.dev/guide/coverage.html) | +| `test:ui` | `pnpm test:ui` | 提供了一个可视化的界面来查看单元测试并与之交互,参考 [Vitest UI](https://vitest.dev/guide/ui) | | `prettier` | `pnpm prettier` | 全局格式化 | | `commit` | `pnpm commit` | commit 钩子 | | `lint` | `pnpm lint` | 全局 eslint 检测,规则参考 [](https://github.com/FightingDesign/fighting-design/blob/master/packages/eslint-config/index.js) | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 048ee69f7..48bfa16f7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,6 +77,7 @@ fighting-design 内部设置了很多的命令,在 [package.json](https://gith | `new` | `pnpm new xxx` | 构建全新组件,生产组件所需要的文件,执行配置文件 [index.ts](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-add-component/index.ts),详情参考 [README.md](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-add-component/README.md) | | `test` | `pnpm test` | 执行单元测试 | | `test:coverage` | `pnpm test:coverage` | 查看单元测试覆盖率,可在终端中生成覆盖率,也可查看项目根目录下的 `coverage/index.html`,参考 [Coverage](https://vitest.dev/guide/coverage.html) | +| `test:ui` | `pnpm test:ui` | 提供了一个可视化的界面来查看单元测试并与之交互,参考 [Vitest UI](https://vitest.dev/guide/ui) | | `prettier` | `pnpm prettier` | 全局格式化 | | `commit` | `pnpm commit` | commit 钩子 | | `lint` | `pnpm lint` | 全局 eslint 检测,规则参考 [](https://github.com/FightingDesign/fighting-design/blob/master/packages/eslint-config/index.js) | diff --git a/docs/docs/contributing.md b/docs/docs/contributing.md index 048ee69f7..48bfa16f7 100644 --- a/docs/docs/contributing.md +++ b/docs/docs/contributing.md @@ -77,6 +77,7 @@ fighting-design 内部设置了很多的命令,在 [package.json](https://gith | `new` | `pnpm new xxx` | 构建全新组件,生产组件所需要的文件,执行配置文件 [index.ts](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-add-component/index.ts),详情参考 [README.md](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-add-component/README.md) | | `test` | `pnpm test` | 执行单元测试 | | `test:coverage` | `pnpm test:coverage` | 查看单元测试覆盖率,可在终端中生成覆盖率,也可查看项目根目录下的 `coverage/index.html`,参考 [Coverage](https://vitest.dev/guide/coverage.html) | +| `test:ui` | `pnpm test:ui` | 提供了一个可视化的界面来查看单元测试并与之交互,参考 [Vitest UI](https://vitest.dev/guide/ui) | | `prettier` | `pnpm prettier` | 全局格式化 | | `commit` | `pnpm commit` | commit 钩子 | | `lint` | `pnpm lint` | 全局 eslint 检测,规则参考 [](https://github.com/FightingDesign/fighting-design/blob/master/packages/eslint-config/index.js) | diff --git a/package.json b/package.json index 997da4266..0d30efc52 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "serve:docs": "pnpm run -C docs serve", "new": "pnpm run -C packages/fighting-add-component new", "test": "vitest", + "test:ui": "vitest --ui", "test:coverage": "vitest --coverage", "prettier": "prettier --write .", "commit": "cz", @@ -46,6 +47,7 @@ "@types/node": "^22.0.0", "@vitejs/plugin-vue": "^5.0.4", "@vitest/coverage-v8": "^2.0.4", + "@vitest/ui": "^2.0.5", "@vue/test-utils": "^2.4.5", "autoprefixer": "^10.4.13", "commitizen": "^4.2.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f5d15c293..843503907 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,6 +36,9 @@ importers: '@vitest/coverage-v8': specifier: ^2.0.4 version: 2.0.4(vitest@2.0.4) + '@vitest/ui': + specifier: ^2.0.5 + version: 2.0.5(vitest@2.0.4) '@vue/test-utils': specifier: ^2.4.5 version: 2.4.5 @@ -89,7 +92,7 @@ importers: version: 2.3.0(@types/node@22.0.0)(vite@4.3.9) vitest: specifier: ^2.0.4 - version: 2.0.4(@types/node@22.0.0)(jsdom@24.0.0)(sass@1.55.0) + version: 2.0.4(@types/node@22.0.0)(@vitest/ui@2.0.5)(jsdom@24.0.0)(sass@1.55.0) vue-tsc: specifier: ^1.8.0 version: 1.8.0(typescript@4.7.4) @@ -123,7 +126,7 @@ importers: version: 1.0.2 ts-node: specifier: ^10.9.1 - version: 10.9.1(@types/node@17.0.42)(typescript@4.8.4) + version: 10.9.1(@types/node@22.0.0)(typescript@4.8.4) packages/fighting-design: {} @@ -1667,6 +1670,10 @@ packages: dev: true optional: true + /@polka/url@1.0.0-next.25: + resolution: {integrity: sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==} + dev: true + /@rollup/pluginutils@5.0.2: resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} engines: {node: '>=14.0.0'} @@ -2141,7 +2148,7 @@ packages: std-env: 3.7.0 test-exclude: 7.0.1 tinyrainbow: 1.2.0 - vitest: 2.0.4(@types/node@22.0.0)(jsdom@24.0.0)(sass@1.55.0) + vitest: 2.0.4(@types/node@22.0.0)(@vitest/ui@2.0.5)(jsdom@24.0.0)(sass@1.55.0) transitivePeerDependencies: - supports-color dev: true @@ -2161,6 +2168,12 @@ packages: tinyrainbow: 1.2.0 dev: true + /@vitest/pretty-format@2.0.5: + resolution: {integrity: sha512-h8k+1oWHfwTkyTkb9egzwNMfJAEx4veaPSnMeKbVSjp4euqGSbQlm5+6VHwTr7u4FJslVVsUG5nopCaAYdOmSQ==} + dependencies: + tinyrainbow: 1.2.0 + dev: true + /@vitest/runner@2.0.4: resolution: {integrity: sha512-Gk+9Su/2H2zNfNdeJR124gZckd5st4YoSuhF1Rebi37qTXKnqYyFCd9KP4vl2cQHbtuVKjfEKrNJxHHCW8thbQ==} dependencies: @@ -2182,6 +2195,21 @@ packages: tinyspy: 3.0.0 dev: true + /@vitest/ui@2.0.5(vitest@2.0.4): + resolution: {integrity: sha512-m+ZpVt/PVi/nbeRKEjdiYeoh0aOfI9zr3Ria9LO7V2PlMETtAXJS3uETEZkc8Be2oOl8mhd7Ew+5SRBXRYncNw==} + peerDependencies: + vitest: 2.0.5 + dependencies: + '@vitest/utils': 2.0.5 + fast-glob: 3.3.2 + fflate: 0.8.2 + flatted: 3.3.1 + pathe: 1.1.2 + sirv: 2.0.4 + tinyrainbow: 1.2.0 + vitest: 2.0.4(@types/node@22.0.0)(@vitest/ui@2.0.5)(jsdom@24.0.0)(sass@1.55.0) + dev: true + /@vitest/utils@2.0.4: resolution: {integrity: sha512-Zc75QuuoJhOBnlo99ZVUkJIuq4Oj0zAkrQ2VzCqNCx6wAwViHEh5Fnp4fiJTE9rA+sAoXRf00Z9xGgfEzV6fzQ==} dependencies: @@ -2191,6 +2219,15 @@ packages: tinyrainbow: 1.2.0 dev: true + /@vitest/utils@2.0.5: + resolution: {integrity: sha512-d8HKbqIcya+GR67mkZbrzhS5kKhtp8dQLcmRZLGTscGVg7yImT82cIrhtn2L8+VujWcy6KZweApgNmPsTAO/UQ==} + dependencies: + '@vitest/pretty-format': 2.0.5 + estree-walker: 3.0.3 + loupe: 3.1.1 + tinyrainbow: 1.2.0 + dev: true + /@volar/language-core@1.7.6: resolution: {integrity: sha512-r+82YGjae8ALzaX+TaESpeBOrp/H5MQnPYZLq4WKd8rsPrCAPbMwelwHLHhFpyjy66BK/cKreJAcvOc6YEwyFA==} dependencies: @@ -3790,6 +3827,17 @@ packages: merge2: 1.4.1 micromatch: 4.0.5 + /fast-glob@3.3.2: + resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} + engines: {node: '>=8.6.0'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.5 + dev: true + /fast-json-stable-stringify@2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} @@ -3810,6 +3858,10 @@ packages: resolution: {integrity: sha512-0Zz1jOzJWERhyhsimS54VTqOteCNwRtIlh8isdL0AXLo0g7xNTfTL7oWrkmCnPhZGocKIkWHBistBrrpoNH3aw==} dev: true + /fflate@0.8.2: + resolution: {integrity: sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==} + dev: true + /figures@2.0.0: resolution: {integrity: sha512-Oa2M9atig69ZkfwiApY8F2Yy+tzMbazyvqv21R0NsSC8floSOC09BbT1ITWAdoMGQvJ/aZnR1KMwdx9tvHnTNA==} engines: {node: '>=4'} @@ -3881,6 +3933,10 @@ packages: /flatted@3.2.7: resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} + /flatted@3.3.1: + resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==} + dev: true + /focus-trap@7.5.4: resolution: {integrity: sha512-N7kHdlgsO/v+iD/dMoJKtsSqs5Dz/dXZVebRgJw23LDk+jMi/974zyiOYDziY2JPp8xivq9BmUGwIJMiuSBi7w==} dependencies: @@ -4989,6 +5045,11 @@ packages: engines: {node: '>=4'} dev: true + /mrmime@2.0.0: + resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==} + engines: {node: '>=10'} + dev: true + /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} @@ -6062,6 +6123,15 @@ packages: engines: {node: '>=14'} dev: true + /sirv@2.0.4: + resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==} + engines: {node: '>= 10'} + dependencies: + '@polka/url': 1.0.0-next.25 + mrmime: 2.0.0 + totalist: 3.0.1 + dev: true + /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -6351,6 +6421,11 @@ packages: dependencies: is-number: 7.0.0 + /totalist@3.0.1: + resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} + engines: {node: '>=6'} + dev: true + /tough-cookie@4.1.3: resolution: {integrity: sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==} engines: {node: '>=6'} @@ -6380,7 +6455,7 @@ packages: code-block-writer: 12.0.0 dev: true - /ts-node@10.9.1(@types/node@17.0.42)(typescript@4.8.4): + /ts-node@10.9.1(@types/node@22.0.0)(typescript@4.7.4): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -6399,19 +6474,19 @@ packages: '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 17.0.42 + '@types/node': 22.0.0 acorn: 8.8.2 acorn-walk: 8.2.0 arg: 4.1.3 create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 4.8.4 + typescript: 4.7.4 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 - dev: false + dev: true - /ts-node@10.9.1(@types/node@22.0.0)(typescript@4.7.4): + /ts-node@10.9.1(@types/node@22.0.0)(typescript@4.8.4): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -6437,10 +6512,10 @@ packages: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 4.7.4 + typescript: 4.8.4 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 - dev: true + dev: false /tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} @@ -6741,7 +6816,7 @@ packages: - universal-cookie dev: false - /vitest@2.0.4(@types/node@22.0.0)(jsdom@24.0.0)(sass@1.55.0): + /vitest@2.0.4(@types/node@22.0.0)(@vitest/ui@2.0.5)(jsdom@24.0.0)(sass@1.55.0): resolution: {integrity: sha512-luNLDpfsnxw5QSW4bISPe6tkxVvv5wn2BBs/PuDRkhXZ319doZyLOBr1sjfB5yCEpTiU7xCAdViM8TNVGPwoog==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -6773,6 +6848,7 @@ packages: '@vitest/runner': 2.0.4 '@vitest/snapshot': 2.0.4 '@vitest/spy': 2.0.4 + '@vitest/ui': 2.0.5(vitest@2.0.4) '@vitest/utils': 2.0.4 chai: 5.1.1 debug: 4.3.6