forked from solana-foundation/explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-setup.specs.ts
More file actions
36 lines (31 loc) · 1.45 KB
/
test-setup.specs.ts
File metadata and controls
36 lines (31 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { vi } from 'vitest';
// Global no-op mock for Logger to suppress console output in all tests.
vi.mock('@/app/shared/lib/logger', () => ({
Logger: { debug: vi.fn(), error: vi.fn(), info: vi.fn(), panic: vi.fn(), warn: vi.fn() },
}));
// Global no-op mock for Sentry to avoid @sentry/nextjs import issues in tests.
vi.mock('@/app/shared/lib/sentry', () => ({
SentryErrorBoundary: ({ children }: { children: React.ReactNode }) => children,
withTraceData: vi.fn(() => ({})),
}));
// Global no-op mock for TokenInfoBatchProvider to prevent network requests in all tests.
// Tests that need to assert on batch behavior should override with a local vi.mock().
vi.mock('@/app/entities/token-info/model/token-info-batch-provider', async () => {
const actual = await vi.importActual<typeof import('@/app/entities/token-info/model/token-info-batch-provider')>(
'@/app/entities/token-info/model/token-info-batch-provider',
);
return {
...actual,
useTokenInfoBatch: () => () => {},
};
});
// Global mock for @solana/kit to prevent real RPC calls (429s) in tests.
// Tests that need custom RPC behavior should override with a local vi.mock().
vi.mock('@solana/kit', async () => {
const actual = await vi.importActual<typeof import('@solana/kit')>('@solana/kit');
const { mockSolanaRpc } = await import('./app/__tests__/mock-rpc');
return {
...actual,
createSolanaRpc: vi.fn(() => mockSolanaRpc()),
};
});