Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { cliTestFiles } from "./cli-test-files.ts";
4
5const root = `${import.meta.dirname}/../..`;
6const vitest = ["/bin/node", "/x/node_modules/vitest/vitest.mjs"];
7const files = (...args: string[]) => cliTestFiles([...vitest, ...args], root);
8const thisFile = "scripts/lib/cli-test-files.test.ts";
9const otherFile = "apps/web/src/lib/assistantCitationNavigation.test.ts";
10
11describe("cliTestFiles", () => {
12 it("returns the named test files, not flag values", async () => {
13 expect(await files("run", "--passWithNoTests", `${thisFile}:12`, "-t", "a name")).toEqual([
14 thisFile,
15 ]);
16 expect(await files("run", "--exclude", otherFile, thisFile)).toEqual([thisFile]);
17 });
18
19 it("keeps every project unless each filter is an existing test file", async () => {
20 expect(await files("run")).toBeUndefined();
21 expect(await files("run", thisFile, "cli-test-files")).toBeUndefined();
22 expect(await files("run", "scripts/lib/missing.test.ts")).toBeUndefined();
23 expect(await files("run", "--unknownFlag", thisFile)).toBeUndefined();
24 expect(await files("run", "--root", "apps/web", thisFile)).toBeUndefined();
25 expect(await files(thisFile)).toBeUndefined();
26 });
27});