fix: mock sharp in tests to prevent CI failure on linux#261
Merged
gaurav-singh-9227 merged 1 commit intobrowserstack:mainfrom Apr 3, 2026
Merged
Conversation
sharp is a native binary module that fails to load in CI (ubuntu-latest) when platform-specific binaries aren't installed. Mock it globally in test setup since tests don't need actual image compression. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gaurav-singh-9227
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sharpnative binary moduleubuntu-latestwheresharpplatform-specific binaries aren't installedProblem
The
sharpmodule is a native binary that requires platform-specific builds. When tests run on CI (ubuntu-latest), thelinux-x64binary may not be available, causing 3 test suites to fail at import time:tests/tools/appautomate.test.tstests/tools/rcaAgent.test.tstests/tools/testmanagement.test.tsThese all transitively import
src/lib/utils.tswhich hasimport sharp from "sharp"at the top level.Fix
tests/setup.ts— global vitest setup file that mockssharpwith a no-op implementationvite.config.ts— points vitest to the setup file viasetupFilesTests don't need actual image compression, so mocking is the correct approach. No CI config changes or production code changes needed.
Test Plan