bun-types-no-globals 1.2.22-canary.20250901T140556 → 1.2.22-canary.20250903T140652

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/test.d.ts +30 -0
  2. package/package.json +1 -1
package/lib/test.d.ts CHANGED
@@ -152,11 +152,41 @@ declare module "bun:test" {
152
152
  type SpiedSetter<T> = JestMock.SpiedSetter<T>;
153
153
  }
154
154
 
155
+ /**
156
+ * Create a spy on an object property or method
157
+ */
155
158
  export function spyOn<T extends object, K extends keyof T>(
156
159
  obj: T,
157
160
  methodOrPropertyValue: K,
158
161
  ): Mock<Extract<T[K], (...args: any[]) => any>>;
159
162
 
163
+ /**
164
+ * Vitest-compatible mocking utilities
165
+ * Provides Vitest-style mocking API for easier migration from Vitest to Bun
166
+ */
167
+ export const vi: {
168
+ /**
169
+ * Create a mock function
170
+ */
171
+ fn: typeof jest.fn;
172
+ /**
173
+ * Create a spy on an object property or method
174
+ */
175
+ spyOn: typeof spyOn;
176
+ /**
177
+ * Mock a module
178
+ */
179
+ module: typeof mock.module;
180
+ /**
181
+ * Restore all mocks to their original implementation
182
+ */
183
+ restoreAllMocks: typeof jest.restoreAllMocks;
184
+ /**
185
+ * Clear all mock state (calls, results, etc.) without restoring original implementation
186
+ */
187
+ clearAllMocks: typeof jest.clearAllMocks;
188
+ };
189
+
160
190
  interface FunctionLike {
161
191
  readonly name: string;
162
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-types-no-globals",
3
- "version": "1.2.22-canary.20250901T140556",
3
+ "version": "1.2.22-canary.20250903T140652",
4
4
  "main": "./generator/index.ts",
5
5
  "types": "./lib/index.d.ts",
6
6
  "description": "TypeScript type definitions for Bun without global types pollution",