Skip to content

Commit 0ddc47b

Browse files
Merge pull request #261 from ruturaj-browserstack/fix/mock-sharp-ci
fix: mock sharp in tests to prevent CI failure on linux
2 parents 41c17eb + 095b798 commit 0ddc47b

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

tests/setup.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { vi } from "vitest";
2+
3+
// Mock sharp globally — it's a native binary module that may not be available in CI
4+
vi.mock("sharp", () => ({
5+
default: vi.fn().mockReturnValue({
6+
png: vi.fn().mockReturnValue({
7+
toBuffer: vi.fn().mockResolvedValue(Buffer.from("mock-image")),
8+
}),
9+
}),
10+
}));

vite.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { defineConfig } from 'vite'
44

55
export default defineConfig({
66
test: {
7-
/* for example, use global to avoid globals imports (describe, test, expect): */
8-
// globals: true,
7+
setupFiles: ['./tests/setup.ts'],
98
},
109
})

0 commit comments

Comments
 (0)