File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1- import { mock } from 'bun:test'
2-
31import type {
42 TestableDb ,
53 TestableDbWhereResult ,
64} from '@codebuff/common/types/contracts/database'
75import type { Logger } from '@codebuff/common/types/contracts/logger'
86
7+ // Compatibility layer: use bun:test mock when available, otherwise identity function
8+ // This allows the utilities to work in both Bun and Jest environments
9+ /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-explicit-any */
10+ const mock : < T extends ( ...args : any [ ] ) => any > ( fn : T ) => T = ( ( ) => {
11+ if ( typeof globalThis . Bun !== 'undefined' ) {
12+ try {
13+ return require ( 'bun:test' ) . mock
14+ } catch {
15+ // Fall through to identity function
16+ }
17+ }
18+ // Identity function for Jest or when bun:test is not available
19+ return < T extends ( ...args : any [ ] ) => any > ( fn : T ) => fn
20+ } ) ( )
21+ /* eslint-enable @typescript-eslint/no-require-imports, @typescript-eslint/no-explicit-any */
22+
923// ============================================================================
1024// Types
1125// ============================================================================
You can’t perform that action at this time.
0 commit comments