mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-09-14 14:01:28 +08:00
f51c11e2c7
77 tests in the latest run failed at module-load with
'Cannot find module ../build/Release/sharp-linux-x64.node'
Root cause: sharp is a transitive dep via @xenova/transformers and
@huggingface/transformers (both deps of @claude-flow/embeddings).
v3/package.json has 'neverBuiltDependencies: [sharp]' — so pnpm
never fetches sharp's prebuilt binary in any environment, including
CI. The threads pool masked this (single Node process, fast-fail
caught and suppressed earlier in some runs); the forks pool exposes
it (each test file is a fresh process; sharp's load fails fresh).
No test in this suite exercises sharp's image-processing behavior —
it's purely a bystander pulled in by transformers' module graph.
Add a global vi.mock('sharp', ...) in __tests__/setup.ts so the
import resolves to a no-op throwing stub. Tests that load
transformers transitively now succeed at module-load; if any test
ever does need real sharp, vi.unmock('sharp') in that file.
Co-Authored-By: RuFlo <ruv@ruv.net>
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
/**
|
|
* V3 Test Setup
|
|
* Global test configuration for Vitest
|
|
*/
|
|
|
|
import { beforeAll, afterAll, vi } from 'vitest';
|
|
|
|
// ── Native binding mocks ─────────────────────────────────────────────
|
|
// `sharp` is a transitive dep via @xenova/transformers + @huggingface/
|
|
// transformers. v3/package.json has `neverBuiltDependencies: ['sharp']`,
|
|
// so sharp's prebuilt binary is never fetched in CI. Any test that
|
|
// transitively pulls in transformers fails at module-load with
|
|
// 'Cannot find module ../build/Release/sharp-linux-x64.node'.
|
|
//
|
|
// No test in this suite actually exercises sharp's image-processing
|
|
// behavior — it's only ever a transitive bystander. Mock it as a no-op
|
|
// so module-load succeeds. If a test ever does need real sharp, it can
|
|
// override locally via vi.unmock('sharp').
|
|
vi.mock('sharp', () => ({
|
|
default: () => {
|
|
throw new Error('sharp is mocked in tests; install it in your project for real image processing');
|
|
},
|
|
}));
|
|
|
|
|
|
// Mock console.warn for cleaner test output
|
|
beforeAll(() => {
|
|
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
});
|
|
|
|
afterAll(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
// Increase timeout for integration tests
|
|
vi.setConfig({
|
|
testTimeout: 30000,
|
|
});
|