tests.CostBudget
The most of each counter an interaction may cost; a counter left out is not limited.
Utilização
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);
});Declaração do tipo
export type CostBudget = Partial<Counts>;Membros 13
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
recordsApplied | number | Não | Records of the batches applied, the UI thread's prop writes included. |
propWrites | number | Não | — |
wastedPropWrites | number | Não | Prop writes of the value the view already had. |
layoutPasses | number | Não | Layouts that computed at least one node. |
wastedLayoutPasses | number | Não | Layout passes after which no box changed. |
nodesLaidOut | number | Não | Nodes the engine computed rather than took from its cache. |
nodesFramed | number | Não | Boxes the renderer took from a pass. |
wastedFrames | number | Não | Boxes taken unchanged. |
measureCalls | number | Não | Leaves measured: each one a miss of the engine's measure cache. |
wastedMeasures | number | Não | Measures that answered what the leaf measured before it was marked dirty. |
uiEntries | number | Não | Calls into the UI-thread kernel: operations received, events, frames. |
wastedUiEntries | number | Não | Events the UI-thread kernel had no handler for. |
viewsCreated | number | Não | Views made with a native view: a flattened node has none. |
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.