Skip to content

Commit

Permalink
feat: Add support for Vitest workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
xeho91 committed Jun 20, 2024
1 parent a08ab64 commit d9c452f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/inputs/getViteConfigPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ describe("getViteConfigPath", () => {
const warningMessage = vi.mocked(core.warning).mock.calls[0][0];
expect(warningMessage).toContain(`${mockWorkingDirectory}/doesNotExist`);
});

it("resolves Vitest workspace file", async (): Promise<void> => {
await expect(
getViteConfigPath(mockWorkingDirectory, "vitest.workspace.js")
).resolves.toMatch('test/mockConfig/vitest.workspace.js');
});
});
10 changes: 8 additions & 2 deletions src/inputs/getViteConfigPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const testFilePath = async (workingDirectory: string, filePath: string) => {
};

const defaultPaths = [
"vitest.config.ts",
"vitest.config.mts",
"vitest.config.cts",
"vitest.config.js",
"vitest.config.mjs",
"vitest.config.cjs",
"vitest.config.ts",
"vitest.config.mts",
"vitest.config.cts",
Expand Down Expand Up @@ -39,9 +45,9 @@ const getViteConfigPath = async (workingDirectory: string, input: string) => {
: `any default location in "${workingDirectory}"`;

core.warning(stripIndent`
Failed to read vite config file at ${searchPath}.
Failed to read vite config file at ${searchPath}.
Make sure you provide the vite-config-path option if you're using a non-default location or name of your config file.
Will not include thresholds in the final report.
`);
return null;
Expand Down
3 changes: 3 additions & 0 deletions test/mockConfig/vitest.workspace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineWorkspace } from "vitest/config";

export default defineWorkspace(["./*"]);

0 comments on commit d9c452f

Please sign in to comment.