From 46d50af478517059abeb1db34793eb5c9a227ab9 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Fri, 17 May 2024 14:53:01 -0700 Subject: [PATCH] Fix vitest not reloading JS files (#3395) Seems like we also need a `vitest.config.ts` at the root of the workspace to override the `watchExclude` setting otherwise `dist` and `node_modules` are still excluded and everytime require a refresh of the vitest UI or restarting the watch. Only thing that was working is if you modified the test files or modified imported files directly from the test --- .chronus/changes/fix-vitest-2024-4-17-21-35-16.md | 8 ++++++++ packages/openapi3/vitest.config.ts | 1 - packages/samples/src/sample-snapshot-testing.ts | 2 +- vitest.config.ts | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .chronus/changes/fix-vitest-2024-4-17-21-35-16.md create mode 100644 vitest.config.ts diff --git a/.chronus/changes/fix-vitest-2024-4-17-21-35-16.md b/.chronus/changes/fix-vitest-2024-4-17-21-35-16.md new file mode 100644 index 0000000000..b762765d84 --- /dev/null +++ b/.chronus/changes/fix-vitest-2024-4-17-21-35-16.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: internal +packages: + - "@typespec/openapi3" +--- + +Fix vitest not reloading JS files diff --git a/packages/openapi3/vitest.config.ts b/packages/openapi3/vitest.config.ts index 113ec4ef24..dca50cce36 100644 --- a/packages/openapi3/vitest.config.ts +++ b/packages/openapi3/vitest.config.ts @@ -6,7 +6,6 @@ export default mergeConfig( defineConfig({ test: { testTimeout: 10000, - watchExclude: ["dist/**"], }, }) ); diff --git a/packages/samples/src/sample-snapshot-testing.ts b/packages/samples/src/sample-snapshot-testing.ts index d6fb232127..d2b3656e33 100644 --- a/packages/samples/src/sample-snapshot-testing.ts +++ b/packages/samples/src/sample-snapshot-testing.ts @@ -50,7 +50,7 @@ export function defineSampleSnaphotTests(config: SampleSnapshotTestOptions) { }); afterAll(async function (context: Readonly) { - if (context.tasks.length !== samples.length) { + if (context.tasks.some((x) => x.mode === "skip")) { return; // Not running the full test suite, so don't bother checking snapshots. } diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000000..d4d739b226 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,4 @@ +import { defineConfig, mergeConfig } from "vitest/config"; +import { defaultTypeSpecVitestConfig } from "./vitest.workspace.js"; + +export default mergeConfig(defaultTypeSpecVitestConfig, defineConfig({}));