tests.ModuleFakes
Fakes for the native modules a test's app calls, by module name, so the app runs without a device.
Verwendung
Provide several native capabilities in a test.
// Provide several native capabilities in a test.
import { Text, appearance, network } from 'kuito';
import { assert, render, screen, test, type ModuleFakes } from 'kuito/tests';
const Status = () => (
<Text>{`${appearance.colorScheme.value} · ${network.state.value.isConnected ? 'online' : 'offline'}`}</Text>
);
// A dark, offline device: one fake per module, live values as their value.
const offlineAtNight: ModuleFakes = {
Appearance: { colorScheme: 'dark', fontScale: 1 },
Network: {
state: { type: 'none', isConnected: false, isInternetReachable: false, details: null },
},
};
test('the status bar reads dark and offline', async () => {
await render(<Status />, { modules: offlineAtNight });
assert.ok(screen.getByText('dark · offline'));
});Typdeklaration
export type ModuleFakes = Readonly<Record<string, ModuleFake>>;Typ
{ readonly [x: string]: Readonly<Record<string, unknown>>;}Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.