From 18099c46ffbaf41fb972d9660c5a4cd2613bdf2d Mon Sep 17 00:00:00 2001 From: Paul Berberian Date: Tue, 11 Jun 2024 11:40:25 +0200 Subject: [PATCH] Add test:unit:watch --- package.json | 56 ++++++++++++------------------------------ vitest.config.unit.mjs | 2 +- 2 files changed, 17 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index 30013a60f22..82326c865b7 100644 --- a/package.json +++ b/package.json @@ -81,45 +81,19 @@ }, "typesVersions": { "*": { - "experimental": [ - "./dist/es2017/experimental/index.d.ts" - ], - "experimental/features": [ - "./dist/es2017/experimental/features/index.d.ts" - ], - "experimental/features/embeds": [ - "./dist/es2017/__GENERATED_CODE/index.d.ts" - ], - "experimental/features/*": [ - "./dist/es2017/experimental/features/*.d.ts" - ], - "experimental/tools": [ - "./dist/es2017/experimental/tools/index.d.ts" - ], - "experimental/tools/*": [ - "./dist/es2017/experimental/tools/*/index.d.ts" - ], - "features": [ - "./dist/es2017/features/list/index.d.ts" - ], - "features/*": [ - "./dist/es2017/features/list/*.d.ts" - ], - "logger": [ - "./dist/es2017/log.d.ts" - ], - "minimal": [ - "./dist/es2017/minimal.d.ts" - ], - "tools": [ - "./dist/es2017/tools/index.d.ts" - ], - "tools/*": [ - "./dist/es2017/tools/*/index.d.ts" - ], - "types": [ - "./dist/es2017/public_types.d.ts" - ] + "experimental": ["./dist/es2017/experimental/index.d.ts"], + "experimental/features": ["./dist/es2017/experimental/features/index.d.ts"], + "experimental/features/embeds": ["./dist/es2017/__GENERATED_CODE/index.d.ts"], + "experimental/features/*": ["./dist/es2017/experimental/features/*.d.ts"], + "experimental/tools": ["./dist/es2017/experimental/tools/index.d.ts"], + "experimental/tools/*": ["./dist/es2017/experimental/tools/*/index.d.ts"], + "features": ["./dist/es2017/features/list/index.d.ts"], + "features/*": ["./dist/es2017/features/list/*.d.ts"], + "logger": ["./dist/es2017/log.d.ts"], + "minimal": ["./dist/es2017/minimal.d.ts"], + "tools": ["./dist/es2017/tools/index.d.ts"], + "tools/*": ["./dist/es2017/tools/*/index.d.ts"], + "types": ["./dist/es2017/public_types.d.ts"] } }, "keywords": [ @@ -184,6 +158,7 @@ "test:memory": "cross-env BROWSER_CONFIG=chrome vitest run tests/memory", "test:memory:chrome:watch": "cross-env BROWSER_CONFIG=chrome vitest watch tests/memory", "test:unit": "vitest --config vitest.config.unit.mjs", + "test:unit:watch": "cross-env WATCH=true vitest --config vitest.config.unit.mjs", "update-version": "npm run version --git-tag-version=false", "version": "./scripts/update-version", "wasm-strip": "node scripts/wasm-strip.mjs dist/mpd-parser.wasm" @@ -268,7 +243,8 @@ "test:integration:firefox:watch": "Launch integration tests in Firefox each times the files update" }, "Unit tests (test particular functions)": { - "test:unit": "Launch unit tests" + "test:unit": "Launch unit tests", + "test:unit:watch": "Launch unit tests and restart them each one of its file changes" }, "Memory tests (test memory usage to avoid memory leaks)": { "test:memory": "Launch memory tests", diff --git a/vitest.config.unit.mjs b/vitest.config.unit.mjs index 4274954f42f..7aa35f109c3 100644 --- a/vitest.config.unit.mjs +++ b/vitest.config.unit.mjs @@ -13,7 +13,7 @@ export default defineConfig({ }, }, test: { - watch: false, + watch: process.env.WATCH === "true", reporters: "dot", include: ["src/**/*.test.ts", "src/__tests__/**/*.ts"], environment: "jsdom",