From f9024cf61580daf3906559b2cc38ce6cda8420bb Mon Sep 17 00:00:00 2001 From: RandomYang Date: Wed, 25 Feb 2026 17:33:00 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BB=8E=20node:test=20=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E5=88=B0=20vitest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.5 --- package.json | 5 +- pnpm-lock.yaml | 252 ++++++++++++++++++++++++++++++ src/converter.mjs | 6 +- test/core/converter-core.test.mjs | 2 +- test/core/parser-core.test.mjs | 2 +- test/core/renderer-core.test.mjs | 2 +- test/integration/convert.test.mjs | 4 +- test/psd/builder.test.mjs | 2 +- test/psd/effects.test.mjs | 2 +- test/psd/text-layer.test.mjs | 2 +- test/render/renderer.test.mjs | 2 +- test/svg/parser.test.mjs | 2 +- test/svg/style-resolver.test.mjs | 2 +- test/svg/text-extractor.test.mjs | 2 +- test/svg/transforms.test.mjs | 2 +- test/svg/walker.test.mjs | 2 +- test/utils/color.test.mjs | 2 +- test/utils/font.test.mjs | 2 +- test/utils/validation.test.mjs | 6 +- 19 files changed, 275 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index f8630f8..b4b16c8 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "type": "module", "scripts": { "start": "node src/index.mjs", - "test": "node --test test/**/*.test.mjs", + "test": "vitest run --silent", "dev": "vite web/", "build:web": "vite build web/" }, @@ -19,6 +19,7 @@ }, "devDependencies": { "vite": "^6.1.0", - "vite-plugin-wasm": "^3.4.1" + "vite-plugin-wasm": "^3.4.1", + "vitest": "^4.0.18" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 11ad7e4..a4774fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,6 +27,9 @@ importers: vite-plugin-wasm: specifier: ^3.4.1 version: 3.5.0(vite@6.4.1) + vitest: + specifier: ^4.0.18 + version: 4.0.18 packages: @@ -186,6 +189,9 @@ packages: cpu: [x64] os: [win32] + '@jridgewell/sourcemap-codec@1.5.5': + resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} + '@resvg/resvg-js-android-arm-eabi@2.6.2': resolution: {integrity: sha512-FrJibrAk6v29eabIPgcTUMPXiEz8ssrAk7TXxsiZzww9UTQ1Z5KAbFJs+Z0Ez+VZTYgnE5IQJqBcoSiMebtPHA==} engines: {node: '>= 10'} @@ -408,9 +414,47 @@ packages: cpu: [x64] os: [win32] + '@standard-schema/spec@1.1.0': + resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} + + '@types/chai@5.2.3': + resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} + + '@types/deep-eql@4.0.2': + resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + '@types/estree@1.0.8': resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} + '@vitest/expect@4.0.18': + resolution: {integrity: sha512-8sCWUyckXXYvx4opfzVY03EOiYVxyNrHS5QxX3DAIi5dpJAAkyJezHCP77VMX4HKA2LDT/Jpfo8i2r5BE3GnQQ==} + + '@vitest/mocker@4.0.18': + resolution: {integrity: sha512-HhVd0MDnzzsgevnOWCBj5Otnzobjy5wLBe4EdeeFGv8luMsGcYqDuFRMcttKWZA5vVO8RFjexVovXvAM4JoJDQ==} + peerDependencies: + msw: ^2.4.9 + vite: ^6.0.0 || ^7.0.0-0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + + '@vitest/pretty-format@4.0.18': + resolution: {integrity: sha512-P24GK3GulZWC5tz87ux0m8OADrQIUVDPIjjj65vBXYG17ZeU3qD7r+MNZ1RNv4l8CGU2vtTRqixrOi9fYk/yKw==} + + '@vitest/runner@4.0.18': + resolution: {integrity: sha512-rpk9y12PGa22Jg6g5M3UVVnTS7+zycIGk9ZNGN+m6tZHKQb7jrP7/77WfZy13Y/EUDd52NDsLRQhYKtv7XfPQw==} + + '@vitest/snapshot@4.0.18': + resolution: {integrity: sha512-PCiV0rcl7jKQjbgYqjtakly6T1uwv/5BQ9SwBLekVg/EaYeQFPiXcgrC2Y7vDMA8dM1SUEAEV82kgSQIlXNMvA==} + + '@vitest/spy@4.0.18': + resolution: {integrity: sha512-cbQt3PTSD7P2OARdVW3qWER5EGq7PHlvE+QfzSC0lbwO+xnt7+XH06ZzFjFRgzUX//JmpxrCu92VdwvEPlWSNw==} + + '@vitest/utils@4.0.18': + resolution: {integrity: sha512-msMRKLMVLWygpK3u2Hybgi4MNjcYJvwTb0Ru09+fOyCXIgT5raYP041DRRdiJiI3k/2U6SEbAETB3YtBrUkCFA==} + '@xmldom/xmldom@0.8.11': resolution: {integrity: sha512-cQzWCtO6C8TQiYl1ruKNn2U6Ao4o4WBBcbL61yJl84x+j5sOWWFU9X7DpND8XZG3daDppSsigMdfAIl2upQBRw==} engines: {node: '>=10.0.0'} @@ -418,14 +462,32 @@ packages: ag-psd@30.1.0: resolution: {integrity: sha512-1ce6o84aC+oVyl83A35HHUniGjwA3piHmGem3J2odBOFRq5p7i4htaco94vePLfOcingZu4fsyospJLwPagkhg==} + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} + base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + chai@6.2.2: + resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==} + engines: {node: '>=18'} + + es-module-lexer@1.7.0: + resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==} + esbuild@0.25.12: resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==} engines: {node: '>=18'} hasBin: true + estree-walker@3.0.3: + resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + + expect-type@1.3.0: + resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==} + engines: {node: '>=12.0.0'} + fdir@6.5.0: resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} engines: {node: '>=12.0.0'} @@ -440,14 +502,23 @@ packages: engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] + magic-string@0.30.21: + resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} + nanoid@3.3.11: resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + obug@2.1.1: + resolution: {integrity: sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==} + pako@2.1.0: resolution: {integrity: sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==} + pathe@2.0.3: + resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -464,14 +535,34 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + siginfo@2.0.0: + resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + source-map-js@1.2.1: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} + stackback@0.0.2: + resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + + std-env@3.10.0: + resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==} + + tinybench@2.9.0: + resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} + + tinyexec@1.0.2: + resolution: {integrity: sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==} + engines: {node: '>=18'} + tinyglobby@0.2.15: resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} engines: {node: '>=12.0.0'} + tinyrainbow@3.0.3: + resolution: {integrity: sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==} + engines: {node: '>=14.0.0'} + vite-plugin-wasm@3.5.0: resolution: {integrity: sha512-X5VWgCnqiQEGb+omhlBVsvTfxikKtoOgAzQ95+BZ8gQ+VfMHIjSHr0wyvXFQCa0eKQ0fKyaL0kWcEnYqBac4lQ==} peerDependencies: @@ -517,6 +608,45 @@ packages: yaml: optional: true + vitest@4.0.18: + resolution: {integrity: sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ==} + engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@opentelemetry/api': ^1.9.0 + '@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0 + '@vitest/browser-playwright': 4.0.18 + '@vitest/browser-preview': 4.0.18 + '@vitest/browser-webdriverio': 4.0.18 + '@vitest/ui': 4.0.18 + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@opentelemetry/api': + optional: true + '@types/node': + optional: true + '@vitest/browser-playwright': + optional: true + '@vitest/browser-preview': + optional: true + '@vitest/browser-webdriverio': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + + why-is-node-running@2.3.0: + resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} + engines: {node: '>=8'} + hasBin: true + snapshots: '@esbuild/aix-ppc64@0.25.12': @@ -597,6 +727,8 @@ snapshots: '@esbuild/win32-x64@0.25.12': optional: true + '@jridgewell/sourcemap-codec@1.5.5': {} + '@resvg/resvg-js-android-arm-eabi@2.6.2': optional: true @@ -725,8 +857,56 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.59.0': optional: true + '@standard-schema/spec@1.1.0': {} + + '@types/chai@5.2.3': + dependencies: + '@types/deep-eql': 4.0.2 + assertion-error: 2.0.1 + + '@types/deep-eql@4.0.2': {} + '@types/estree@1.0.8': {} + '@vitest/expect@4.0.18': + dependencies: + '@standard-schema/spec': 1.1.0 + '@types/chai': 5.2.3 + '@vitest/spy': 4.0.18 + '@vitest/utils': 4.0.18 + chai: 6.2.2 + tinyrainbow: 3.0.3 + + '@vitest/mocker@4.0.18(vite@6.4.1)': + dependencies: + '@vitest/spy': 4.0.18 + estree-walker: 3.0.3 + magic-string: 0.30.21 + optionalDependencies: + vite: 6.4.1 + + '@vitest/pretty-format@4.0.18': + dependencies: + tinyrainbow: 3.0.3 + + '@vitest/runner@4.0.18': + dependencies: + '@vitest/utils': 4.0.18 + pathe: 2.0.3 + + '@vitest/snapshot@4.0.18': + dependencies: + '@vitest/pretty-format': 4.0.18 + magic-string: 0.30.21 + pathe: 2.0.3 + + '@vitest/spy@4.0.18': {} + + '@vitest/utils@4.0.18': + dependencies: + '@vitest/pretty-format': 4.0.18 + tinyrainbow: 3.0.3 + '@xmldom/xmldom@0.8.11': {} ag-psd@30.1.0: @@ -734,8 +914,14 @@ snapshots: base64-js: 1.5.1 pako: 2.1.0 + assertion-error@2.0.1: {} + base64-js@1.5.1: {} + chai@6.2.2: {} + + es-module-lexer@1.7.0: {} + esbuild@0.25.12: optionalDependencies: '@esbuild/aix-ppc64': 0.25.12 @@ -765,6 +951,12 @@ snapshots: '@esbuild/win32-ia32': 0.25.12 '@esbuild/win32-x64': 0.25.12 + estree-walker@3.0.3: + dependencies: + '@types/estree': 1.0.8 + + expect-type@1.3.0: {} + fdir@6.5.0(picomatch@4.0.3): optionalDependencies: picomatch: 4.0.3 @@ -772,10 +964,18 @@ snapshots: fsevents@2.3.3: optional: true + magic-string@0.30.21: + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + nanoid@3.3.11: {} + obug@2.1.1: {} + pako@2.1.0: {} + pathe@2.0.3: {} + picocolors@1.1.1: {} picomatch@4.0.3: {} @@ -817,13 +1017,25 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.59.0 fsevents: 2.3.3 + siginfo@2.0.0: {} + source-map-js@1.2.1: {} + stackback@0.0.2: {} + + std-env@3.10.0: {} + + tinybench@2.9.0: {} + + tinyexec@1.0.2: {} + tinyglobby@0.2.15: dependencies: fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 + tinyrainbow@3.0.3: {} + vite-plugin-wasm@3.5.0(vite@6.4.1): dependencies: vite: 6.4.1 @@ -838,3 +1050,43 @@ snapshots: tinyglobby: 0.2.15 optionalDependencies: fsevents: 2.3.3 + + vitest@4.0.18: + dependencies: + '@vitest/expect': 4.0.18 + '@vitest/mocker': 4.0.18(vite@6.4.1) + '@vitest/pretty-format': 4.0.18 + '@vitest/runner': 4.0.18 + '@vitest/snapshot': 4.0.18 + '@vitest/spy': 4.0.18 + '@vitest/utils': 4.0.18 + es-module-lexer: 1.7.0 + expect-type: 1.3.0 + magic-string: 0.30.21 + obug: 2.1.1 + pathe: 2.0.3 + picomatch: 4.0.3 + std-env: 3.10.0 + tinybench: 2.9.0 + tinyexec: 1.0.2 + tinyglobby: 0.2.15 + tinyrainbow: 3.0.3 + vite: 6.4.1 + why-is-node-running: 2.3.0 + transitivePeerDependencies: + - jiti + - less + - lightningcss + - msw + - sass + - sass-embedded + - stylus + - sugarss + - terser + - tsx + - yaml + + why-is-node-running@2.3.0: + dependencies: + siginfo: 2.0.0 + stackback: 0.0.2 diff --git a/src/converter.mjs b/src/converter.mjs index 39907d6..9666bfa 100644 --- a/src/converter.mjs +++ b/src/converter.mjs @@ -104,16 +104,12 @@ export async function convertSvgToPsd(inputPath, outputPath, options = {}) { buildTextLayer(desc, svgRoot, w, h, s), onProgress: (current, total) => { completed = current; - process.stdout.write(`\r 渲染: ${current}/${total} 图层`); + console.log(` 渲染: ${current}/${total} 图层`); }, }); console.log(`图层树: ${layerCount} 个图层`); - if (completed > 0) { - process.stdout.write("\n"); - } - // 3. 写入 PSD const buffer = writePsdBuffer(psd, { invalidateTextLayers: true, diff --git a/test/core/converter-core.test.mjs b/test/core/converter-core.test.mjs index 57272bf..ff6b3c7 100644 --- a/test/core/converter-core.test.mjs +++ b/test/core/converter-core.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { DOMParser } from "@xmldom/xmldom"; import { convertSvg, enrichTextDescriptors, countAllLayers } from "../../src/core/converter-core.mjs"; diff --git a/test/core/parser-core.test.mjs b/test/core/parser-core.test.mjs index bbb27d6..3161dc5 100644 --- a/test/core/parser-core.test.mjs +++ b/test/core/parser-core.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { DOMParser } from "@xmldom/xmldom"; import { parseSvgFromDocument, parseViewBox } from "../../src/core/parser-core.mjs"; diff --git a/test/core/renderer-core.test.mjs b/test/core/renderer-core.test.mjs index 903e315..87e426d 100644 --- a/test/core/renderer-core.test.mjs +++ b/test/core/renderer-core.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { DOMParser, XMLSerializer } from "@xmldom/xmldom"; import { diff --git a/test/integration/convert.test.mjs b/test/integration/convert.test.mjs index 33a1a83..fe9f120 100644 --- a/test/integration/convert.test.mjs +++ b/test/integration/convert.test.mjs @@ -1,4 +1,4 @@ -import { describe, it, after } from "node:test"; +import { describe, it, afterAll } from "vitest"; import assert from "node:assert/strict"; import fs from "fs"; import path from "path"; @@ -16,7 +16,7 @@ if (!fs.existsSync(outputDir)) { const outputs = []; -after(() => { +afterAll(() => { for (const f of outputs) { try { fs.unlinkSync(f); } catch {} } diff --git a/test/psd/builder.test.mjs b/test/psd/builder.test.mjs index a72e45b..d90b004 100644 --- a/test/psd/builder.test.mjs +++ b/test/psd/builder.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { parseSvgString } from "../../src/svg/parser.mjs"; import { buildPsd } from "../../src/psd/builder.mjs"; diff --git a/test/psd/effects.test.mjs b/test/psd/effects.test.mjs index c121a0f..48fc669 100644 --- a/test/psd/effects.test.mjs +++ b/test/psd/effects.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { toPsdOpacity, toPsdBlendMode, BLEND_MODE_MAP } from "../../src/psd/effects.mjs"; diff --git a/test/psd/text-layer.test.mjs b/test/psd/text-layer.test.mjs index 0076775..7f504eb 100644 --- a/test/psd/text-layer.test.mjs +++ b/test/psd/text-layer.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { parseSvgString } from "../../src/svg/parser.mjs"; import { extractTextInfo } from "../../src/svg/text-extractor.mjs"; diff --git a/test/render/renderer.test.mjs b/test/render/renderer.test.mjs index f21635a..20d059e 100644 --- a/test/render/renderer.test.mjs +++ b/test/render/renderer.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { parseSvgString } from "../../src/svg/parser.mjs"; import { buildStandaloneSvg, renderSvgString } from "../../src/render/renderer.mjs"; diff --git a/test/svg/parser.test.mjs b/test/svg/parser.test.mjs index 9d3f27a..cc9f81f 100644 --- a/test/svg/parser.test.mjs +++ b/test/svg/parser.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import path from "path"; import { fileURLToPath } from "url"; diff --git a/test/svg/style-resolver.test.mjs b/test/svg/style-resolver.test.mjs index b079632..076ce65 100644 --- a/test/svg/style-resolver.test.mjs +++ b/test/svg/style-resolver.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { DOMParser } from "@xmldom/xmldom"; import { parseStyleAttr, getStyleValue, resolveStyles } from "../../src/svg/style-resolver.mjs"; diff --git a/test/svg/text-extractor.test.mjs b/test/svg/text-extractor.test.mjs index b0a78a4..766d14b 100644 --- a/test/svg/text-extractor.test.mjs +++ b/test/svg/text-extractor.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { parseSvgString } from "../../src/svg/parser.mjs"; import { extractTextInfo } from "../../src/svg/text-extractor.mjs"; diff --git a/test/svg/transforms.test.mjs b/test/svg/transforms.test.mjs index a451d04..2856896 100644 --- a/test/svg/transforms.test.mjs +++ b/test/svg/transforms.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { identity, parseTransform, multiply, transformPoint, getTranslation } from "../../src/svg/transforms.mjs"; diff --git a/test/svg/walker.test.mjs b/test/svg/walker.test.mjs index 09e5db3..11cda90 100644 --- a/test/svg/walker.test.mjs +++ b/test/svg/walker.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { parseSvgString } from "../../src/svg/parser.mjs"; import { walkSvg } from "../../src/svg/walker.mjs"; diff --git a/test/utils/color.test.mjs b/test/utils/color.test.mjs index c7bc658..743963a 100644 --- a/test/utils/color.test.mjs +++ b/test/utils/color.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { parseColor } from "../../src/utils/color.mjs"; diff --git a/test/utils/font.test.mjs b/test/utils/font.test.mjs index 7b59280..83b2fab 100644 --- a/test/utils/font.test.mjs +++ b/test/utils/font.test.mjs @@ -1,4 +1,4 @@ -import { describe, it } from "node:test"; +import { describe, it } from "vitest"; import assert from "node:assert/strict"; import { toPostScriptName, cleanFontFamily, isBoldWeight } from "../../src/utils/font.mjs"; diff --git a/test/utils/validation.test.mjs b/test/utils/validation.test.mjs index db59b90..49e9669 100644 --- a/test/utils/validation.test.mjs +++ b/test/utils/validation.test.mjs @@ -1,4 +1,4 @@ -import { describe, it, before, after } from "node:test"; +import { describe, it, beforeAll, afterAll } from "vitest"; import assert from "node:assert/strict"; import fs from "fs"; import path from "path"; @@ -12,12 +12,12 @@ describe("validateInput", () => { const tmpEmpty = path.join(fixturesDir, "__empty_test.svg"); const tmpTxt = path.join(fixturesDir, "__test.txt"); - before(() => { + beforeAll(() => { fs.writeFileSync(tmpEmpty, ""); fs.writeFileSync(tmpTxt, "hello"); }); - after(() => { + afterAll(() => { try { fs.unlinkSync(tmpEmpty); } catch {} try { fs.unlinkSync(tmpTxt); } catch {} });