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 }).
Usage
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 });
});Signatures
(interaction: () => unknown): Promise<Cost>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
interaction | () => unknown | Yes | — |
Returns
Promise<Cost>
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.