tests.CostBudget
The most of each counter an interaction may cost; a counter left out is not limited.
Usage
Limit the work an interaction performs.
// Limit the work an interaction performs.
import { Button, Text, VStack, signal } from 'kuito';
import { costOf, press, render, screen, test, type CostBudget } from 'kuito/tests';
function Like() {
const liked = signal(false);
return (
<VStack>
<Text color={liked.value ? '#ff3b30' : '#8e8e93'}>♥</Text>
<Button onPress={() => (liked.value = !liked.value)}>Like</Button>
</VStack>
);
}
// A color change repaints one view: no layout, no new views.
const repaintOnly: CostBudget = { layoutPasses: 0, viewsCreated: 0, propWrites: 1 };
test('a like only repaints the heart', async () => {
await render(<Like />);
(await costOf(() => press(screen.getByText('Like')))).toStayWithin(repaintOnly);
});Type declaration
export type CostBudget = Partial<Counts>;Members 13
| Name | Type | Required | Description |
|---|---|---|---|
recordsApplied | number | No | Records of the batches applied, the UI thread's prop writes included. |
propWrites | number | No | — |
wastedPropWrites | number | No | Prop writes of the value the view already had. |
layoutPasses | number | No | Layouts that computed at least one node. |
wastedLayoutPasses | number | No | Layout passes after which no box changed. |
nodesLaidOut | number | No | Nodes the engine computed rather than took from its cache. |
nodesFramed | number | No | Boxes the renderer took from a pass. |
wastedFrames | number | No | Boxes taken unchanged. |
measureCalls | number | No | Leaves measured: each one a miss of the engine's measure cache. |
wastedMeasures | number | No | Measures that answered what the leaf measured before it was marked dirty. |
uiEntries | number | No | Calls into the UI-thread kernel: operations received, events, frames. |
wastedUiEntries | number | No | Events the UI-thread kernel had no handler for. |
viewsCreated | number | No | Views made with a native view: a flattened node has none. |
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.