hermes-test 1.0.1 → 1.0.3

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.
package/globals.d.ts CHANGED
@@ -1,19 +1,22 @@
1
1
  declare global {
2
2
  interface HtMockFetch {
3
- (...handlers: import('hermes-test').FetchHandler[]): void
4
- overwrite(...handlers: import('hermes-test').FetchHandler[]): void
5
- reset(): void
6
- clear(): void
3
+ (...handlers: import('hermes-test').FetchHandler[]): void;
4
+ overwrite(...handlers: import('hermes-test').FetchHandler[]): void;
5
+ reset(): void;
6
+ clear(): void;
7
7
  }
8
8
 
9
9
  interface HtMock {
10
- (modulePath: string, factory: () => Record<string, unknown>): void
11
- fetch: HtMockFetch
10
+ (modulePath: string, factory: () => unknown): void;
11
+ fetch: HtMockFetch;
12
12
  }
13
13
 
14
14
  /** Shallow render: auto-mock child components so the parent renders without deep dependencies. */
15
- function htShallow(componentPath: string): void
15
+ function htShallow(componentPath: string): void;
16
16
 
17
- const ht: { mock: HtMock; shallow: typeof htShallow }
17
+ /** Remove a previously registered mock so the real module is used. No-op at runtime (bundler directive). */
18
+ function htUnmock(modulePath: string): void;
19
+
20
+ const ht: { mock: HtMock; shallow: typeof htShallow; unmock: typeof htUnmock };
18
21
  }
19
- export {}
22
+ export {};
package/index.d.ts CHANGED
@@ -2,27 +2,26 @@
2
2
 
3
3
  // --- Spy ---
4
4
 
5
- export type Spy<F extends (...args: any[]) => any = (...args: any[]) => any> =
6
- F & {
7
- readonly calls: ReadonlyArray<Parameters<F>>;
8
- readonly callCount: number;
9
- readonly returnValues: ReadonlyArray<ReturnType<F>>;
10
- reset(): void;
11
- setImpl(impl: F): Spy<F>;
12
- returns(value: ReturnType<F>): Spy<F>;
13
- mockImplementation(fn: F): Spy<F>;
14
- mockImplementationOnce(fn: F): Spy<F>;
15
- mockReturnValue(value: ReturnType<F>): Spy<F>;
16
- mockReturnValueOnce(value: ReturnType<F>): Spy<F>;
17
- mockResolvedValue<V>(value: V): Spy<(...args: Parameters<F>) => Promise<V>>;
18
- mockResolvedValueOnce<V>(value: V): Spy<F>;
19
- mockRejectedValue(value: unknown): Spy<F>;
20
- mockRejectedValueOnce(value: unknown): Spy<F>;
21
- mockClear(): void;
22
- mockReset(): void;
23
- mockRestore(): void;
24
- readonly _isSpy: true;
25
- };
5
+ export type Spy<F extends (...args: any[]) => any = (...args: any[]) => any> = F & {
6
+ readonly calls: ReadonlyArray<Parameters<F>>;
7
+ readonly callCount: number;
8
+ readonly returnValues: ReadonlyArray<ReturnType<F>>;
9
+ reset(): void;
10
+ setImpl(impl: F): Spy<F>;
11
+ returns(value: ReturnType<F>): Spy<F>;
12
+ mockImplementation(fn: F): Spy<F>;
13
+ mockImplementationOnce(fn: F): Spy<F>;
14
+ mockReturnValue(value: ReturnType<F>): Spy<F>;
15
+ mockReturnValueOnce(value: ReturnType<F>): Spy<F>;
16
+ mockResolvedValue<V>(value: V): Spy<(...args: Parameters<F>) => Promise<V>>;
17
+ mockResolvedValueOnce<V>(value: V): Spy<F>;
18
+ mockRejectedValue(value: unknown): Spy<F>;
19
+ mockRejectedValueOnce(value: unknown): Spy<F>;
20
+ mockClear(): void;
21
+ mockReset(): void;
22
+ mockRestore(): void;
23
+ readonly _isSpy: true;
24
+ };
26
25
 
27
26
  export function spy(): Spy<(...args: any[]) => undefined>;
28
27
  export function spy<F extends (...args: any[]) => any>(impl: F): Spy<F>;
@@ -214,7 +213,9 @@ export const fireEvent: FireEventObject;
214
213
 
215
214
  export function useMock<T extends Record<string, unknown>>(
216
215
  moduleExports: T,
217
- implementation: Partial<{ [K in keyof T]: T[K] extends (...args: any[]) => any ? Spy<T[K]> | T[K] : T[K] }>,
216
+ implementation: Partial<{
217
+ [K in keyof T]: T[K] extends (...args: any[]) => any ? Spy<T[K]> | T[K] : T[K];
218
+ }>,
218
219
  ): void;
219
220
 
220
221
  // --- Fetch mocking types ---
@@ -262,11 +263,17 @@ export interface StoreContext {
262
263
  getState(): any;
263
264
  setState(state: Record<string, any>): void;
264
265
  patchState(partial: Record<string, any>): void;
265
- renderHookWithReduxStore<T>(hookFn: (props?: any) => T, options?: { initialProps?: any }): HookResult<T>;
266
+ renderHookWithReduxStore<T>(
267
+ hookFn: (props?: any) => T,
268
+ options?: { initialProps?: any },
269
+ ): HookResult<T>;
266
270
  }
267
271
 
268
272
  export function withStore(initialState?: Record<string, any>): StoreContext;
269
- export function withAppReducer(reducer: (state: any, action: any) => any, preloadedState?: Record<string, any>): StoreContext;
273
+ export function withAppReducer(
274
+ reducer: (state: any, action: any) => any,
275
+ preloadedState?: Record<string, any>,
276
+ ): StoreContext;
270
277
 
271
278
  // --- Timers ---
272
279
 
@@ -293,9 +300,9 @@ declare global {
293
300
  }
294
301
 
295
302
  interface HtMock {
296
- (modulePath: string, factory: () => Record<string, unknown>): void;
303
+ (modulePath: string, factory: () => unknown): void;
297
304
  fetch: HtMockFetch;
298
305
  }
299
306
 
300
- const ht: { mock: HtMock };
307
+ const ht: { mock: HtMock; unmock: (modulePath: string) => void };
301
308
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-test",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "26-64x faster than Jest. A test runner built for React Native and Expo. One esbuild pass, one process, zero Babel.",
5
5
  "main": "src/index.ts",
6
6
  "types": "index.d.ts",
@@ -54,9 +54,9 @@
54
54
  "react": ">=18"
55
55
  },
56
56
  "optionalDependencies": {
57
- "@hermes-test/darwin-arm64": "1.0.1",
58
- "@hermes-test/darwin-x64": "1.0.1",
59
- "@hermes-test/linux-x64": "1.0.1"
57
+ "@hermes-test/darwin-arm64": "1.0.3",
58
+ "@hermes-test/darwin-x64": "1.0.3",
59
+ "@hermes-test/linux-x64": "1.0.3"
60
60
  },
61
61
  "files": [
62
62
  "src/",