From c000197a6c58397f8f269a0c2ccbe7312038e114 Mon Sep 17 00:00:00 2001 From: Christian Schurr Date: Mon, 9 Nov 2026 13:24:56 +0100 Subject: [PATCH] test: use the .test.ts suffix for test files Rename the test files in src/__tests__ to *.test.ts and include only that suffix in vitest. Helpers (utils.ts) and type tests (*.test-d.ts) no longer match, so the exclude list is gone. knip uses vitest's include as its test entries when it's set, so it stopped seeing types.test-d.ts and reported it as unused. Add it to knip's entry list. --- knip.json | 2 +- src/__tests__/{index.ts => index.test.ts} | 0 src/__tests__/{path-parts.ts => path-parts.test.ts} | 0 src/__tests__/{properties.ts => properties.test.ts} | 0 vitest.config.mts | 13 ++----------- 5 files changed, 3 insertions(+), 12 deletions(-) rename src/__tests__/{index.ts => index.test.ts} (100%) rename src/__tests__/{path-parts.ts => path-parts.test.ts} (100%) rename src/__tests__/{properties.ts => properties.test.ts} (100%) diff --git a/knip.json b/knip.json index b37bb19..8d7acb0 100644 --- a/knip.json +++ b/knip.json @@ -1,5 +1,5 @@ { "$schema": "https://unpkg.com/knip@6/schema.json", - "entry": ["scripts/*.mjs"], + "entry": ["scripts/*.mjs", "src/**/*.test-d.ts"], "project": ["src/**/*.ts", "scripts/*.mjs"] } diff --git a/src/__tests__/index.ts b/src/__tests__/index.test.ts similarity index 100% rename from src/__tests__/index.ts rename to src/__tests__/index.test.ts diff --git a/src/__tests__/path-parts.ts b/src/__tests__/path-parts.test.ts similarity index 100% rename from src/__tests__/path-parts.ts rename to src/__tests__/path-parts.test.ts diff --git a/src/__tests__/properties.ts b/src/__tests__/properties.test.ts similarity index 100% rename from src/__tests__/properties.ts rename to src/__tests__/properties.test.ts diff --git a/vitest.config.mts b/vitest.config.mts index c1ab2d0..e235735 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -1,17 +1,8 @@ -import {configDefaults, defineConfig, type ViteUserConfig} from 'vitest/config' +import {defineConfig, type ViteUserConfig} from 'vitest/config' const config: ViteUserConfig = defineConfig({ test: { - include: ['src/**/__tests__/**/*.ts'], - exclude: [ - ...configDefaults.exclude, - // Shared helpers, not a test file. - 'src/__tests__/utils.ts', - // Type tests: `npm run typecheck` checks them. At runtime every - // `expectTypeOf` call is a no-op, so they would pass without testing - // anything. - 'src/**/*.test-d.ts', - ], + include: ['src/**/__tests__/**/*.test.ts'], coverage: { provider: 'v8', include: ['src/**/*.ts'],