From 1b76248e0e5506ee414eb6d128ef77dbc62e264e Mon Sep 17 00:00:00 2001 From: Matt Pocock Date: Mon, 20 Oct 2025 09:19:41 +0100 Subject: [PATCH] Add failing test reproducing issue #95 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vitest workspace configs cause evalite to pick up wrong files. Test demonstrates: - Unit tests run when they shouldn't - Eval files ignored - Workspace include patterns override evalite patterns Refs #95 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../fixtures/vitest-workspace/basics.eval.ts | 17 ++++++++++++ .../fixtures/vitest-workspace/unit.test.ts | 6 +++++ .../fixtures/vitest-workspace/vite.config.ts | 14 ++++++++++ .../tests/vitest-workspace.test.ts | 26 +++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 packages/evalite-tests/tests/fixtures/vitest-workspace/basics.eval.ts create mode 100644 packages/evalite-tests/tests/fixtures/vitest-workspace/unit.test.ts create mode 100644 packages/evalite-tests/tests/fixtures/vitest-workspace/vite.config.ts create mode 100644 packages/evalite-tests/tests/vitest-workspace.test.ts diff --git a/packages/evalite-tests/tests/fixtures/vitest-workspace/basics.eval.ts b/packages/evalite-tests/tests/fixtures/vitest-workspace/basics.eval.ts new file mode 100644 index 00000000..99455e41 --- /dev/null +++ b/packages/evalite-tests/tests/fixtures/vitest-workspace/basics.eval.ts @@ -0,0 +1,17 @@ +import { evalite } from "evalite"; +import { Levenshtein } from "autoevals"; + +evalite("Basics", { + data: () => { + return [ + { + input: "abc", + expected: "abcdef", + }, + ]; + }, + task: async (input) => { + return input + "def"; + }, + scorers: [Levenshtein], +}); diff --git a/packages/evalite-tests/tests/fixtures/vitest-workspace/unit.test.ts b/packages/evalite-tests/tests/fixtures/vitest-workspace/unit.test.ts new file mode 100644 index 00000000..c5b57daa --- /dev/null +++ b/packages/evalite-tests/tests/fixtures/vitest-workspace/unit.test.ts @@ -0,0 +1,6 @@ +import { it, expect } from "vitest"; + +it("should not run this unit test when running evalite", () => { + console.log("UNIT_TEST_RAN"); + expect(1 + 1).toBe(2); +}); diff --git a/packages/evalite-tests/tests/fixtures/vitest-workspace/vite.config.ts b/packages/evalite-tests/tests/fixtures/vitest-workspace/vite.config.ts new file mode 100644 index 00000000..aa6102fe --- /dev/null +++ b/packages/evalite-tests/tests/fixtures/vitest-workspace/vite.config.ts @@ -0,0 +1,14 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + workspace: [ + { + test: { + name: "unit", + include: ["**/*.test.ts"], + }, + }, + ], + }, +}); diff --git a/packages/evalite-tests/tests/vitest-workspace.test.ts b/packages/evalite-tests/tests/vitest-workspace.test.ts new file mode 100644 index 00000000..5d09e51a --- /dev/null +++ b/packages/evalite-tests/tests/vitest-workspace.test.ts @@ -0,0 +1,26 @@ +import { expect, it } from "vitest"; +import { getEvalsAsRecordViaStorage, loadFixture } from "./test-utils.js"; + +it("Should run evalite successfully despite vitest workspace config", async () => { + await using fixture = await loadFixture("vitest-workspace"); + + await fixture.run({ + mode: "run-once-and-exit", + }); + + const output = fixture.getOutput(); + + // Should not have "No suite present" or "No result present" errors + expect(output).not.toContain("No suite present"); + expect(output).not.toContain("No result present"); + + // Should not have run the unit test + // TODO: This currently fails - workspace config causes evalite to pick up .test.ts files + expect(output).not.toContain("UNIT_TEST_RAN"); + + // Should have run the eval successfully + // TODO: This currently fails - workspace config prevents .eval.ts files from being found + const evals = await getEvalsAsRecordViaStorage(fixture.storage); + expect(evals.Basics).toHaveLength(1); + expect(evals.Basics?.[0]?.status).toBe("success"); +});