/** * Vitest adapter for the native-boundary fake: * `@codemagic/react-native-patch/vitest`. * * React Native's own entry is Flow source that Node cannot load, so under * Vitest this adapter mocks the whole `react-native` module with just what the * SDK reads from it: `TurboModuleRegistry` (serving the fake as * `NativeCodemagicPatch`), `AppState` and `DeviceEventEmitter`. Anything else * imported from `react-native` (`View`, `Text`, ...) is undefined under this * mock; render with `react-dom` in a jsdom environment instead. * * Needs the `codemagicPatch()` plugin from * `@codemagic/react-native-patch/vitest-plugin`: Vitest's module mocks do not * reach the package's CommonJS build, so the plugin points the package entry * at its TypeScript source, which Vitest transforms itself. * * Isolation contract: * - There is one current fake per test file. It lives on `globalThis`, so * `vi.resetModules()` does not drop it. * - `installPatchFake(seed)` replaces the current fake. An SDK instance that * was already imported keeps the native module it captured at import and the * state it hydrated, so install before importing the app graph, or call * `loadSdk()` after installing. * - `loadSdk()` runs `vi.resetModules()` and imports a fresh SDK, which * hydrates from the current fake, under a fresh `react-native` mock (no * `AppState` listener of an earlier load survives). Modules that import the * SDK must be imported again after it. React and other dependencies Vitest * leaves to Node are not reset, so a test's React and the SDK's stay one * instance. It does not reset the fake: failures, server answers and * packages downloaded so far stay. A new scenario means a new * `installPatchFake(seed)`. * - `loadSdk()` cancels the pending `ON_NEXT_SUSPEND` activation timer of the * SDK the previous `loadSdk()` imported, so it cannot reload the bundle * during a later scenario. An SDK imported without `loadSdk()` (install, * then a plain import) is not disposed this way. */ import type { PatchFake, PatchFakeSeed } from "./types"; export type { PatchFake, PatchFakeMethod, PatchFakeSeed, PatchFakeServer, PatchPackageSeed, } from "./types"; /** * Make `seed` the native state the SDK sees, replacing any earlier fake. Only * SDK instances imported after this call use it: call it before importing the * app graph (a setup file does), or follow it with `loadSdk()`. */ export declare function installPatchFake(seed?: PatchFakeSeed): PatchFake; /** * Reset Vitest's module registry and import a fresh SDK, which hydrates from * the current fake. Modules that import the SDK must be imported again after * this to share the fresh instance. */ export declare function loadSdk(): Promise; //# sourceMappingURL=vitest.d.ts.map