tests.costOf
Runs interaction once the app has settled, settles what it started, and
returns what it cost the main thread in counts (docs/testing.md#cost-budgets):
(await costOf(() => press(like))).toStayWithin({ layoutPasses: 0 }).
Verwendung
Add an interaction budget
import { Pressable, Text, signal } from 'kuito';
import { costOf, press, render, screen, test } from 'kuito/tests';
function Like() {
const liked = signal(false);
return (
<Pressable onPress={() => (liked.value = !liked.value)} opacity={liked.value ? 1 : 0.6}>
<Text>Like</Text>
</Pressable>
);
}
test('a like lays nothing out', async () => {
await render(<Like />);
const cost = await costOf(() => press(screen.getByText('Like')));
cost.toStayWithin({ layoutPasses: 0, measureCalls: 0, viewsCreated: 0 });
});Signaturen
(interaction: () => unknown): Promise<Cost>Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
interaction | () => unknown | Ja | — |
Rückgabe
Promise<Cost>
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.