Skip to content

Commit

Permalink
feat(vitest-plugin): always run codspeed benchmarks when using the pl…
Browse files Browse the repository at this point in the history
…ugin, as hooks are not supported in the default vitest benchmark runner
  • Loading branch information
adriencaccia committed Jan 24, 2024
1 parent 248b470 commit 09429f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/vitest-plugin/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe("codSpeedPlugin", () => {
expect(applyPlugin).toBe(false);
});

it("should not apply the plugin when there is no instrumentation", async () => {
it("should apply the plugin when there is no instrumentation", async () => {
coreMocks.Measurement.isInstrumented.mockReturnValue(false);

const applyPlugin = applyPluginFunction(
Expand All @@ -52,9 +52,9 @@ describe("codSpeedPlugin", () => {
);

expect(console.warn).toHaveBeenCalledWith(
"[CodSpeed] bench detected but no instrumentation found, falling back to default vitest runner"
"[CodSpeed] bench detected but no instrumentation found"
);
expect(applyPlugin).toBe(false);
expect(applyPlugin).toBe(true);
});

it("should apply the plugin when there is instrumentation", async () => {
Expand Down
5 changes: 1 addition & 4 deletions packages/vitest-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ export default function codspeedPlugin(): Plugin {
return false;
}
if (!Measurement.isInstrumented()) {
console.warn(
`[CodSpeed] bench detected but no instrumentation found, falling back to default vitest runner`
);
return false;
console.warn("[CodSpeed] bench detected but no instrumentation found");
}
return true;
},
Expand Down

0 comments on commit 09429f2

Please sign in to comment.