Skip to content

Commit

Permalink
Fix vitest not reloading JS files (#3395)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
timotheeguerin authored May 17, 2024
1 parent e56969c commit 46d50af
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .chronus/changes/fix-vitest-2024-4-17-21-35-16.md
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion packages/openapi3/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default mergeConfig(
defineConfig({
test: {
testTimeout: 10000,
watchExclude: ["dist/**"],
},
})
);
2 changes: 1 addition & 1 deletion packages/samples/src/sample-snapshot-testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function defineSampleSnaphotTests(config: SampleSnapshotTestOptions) {
});

afterAll(async function (context: Readonly<Suite | File>) {
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.
}

Expand Down
4 changes: 4 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineConfig, mergeConfig } from "vitest/config";
import { defaultTypeSpecVitestConfig } from "./vitest.workspace.js";

export default mergeConfig(defaultTypeSpecVitestConfig, defineConfig({}));

0 comments on commit 46d50af

Please sign in to comment.