tests.CostBudget
The most of each counter an interaction may cost; a counter left out is not limited.
Verwendung
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);
});Typdeklaration
export type CostBudget = Partial<Counts>;Mitglieder 13
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
recordsApplied | number | Nein | Records of the batches applied, the UI thread's prop writes included. |
propWrites | number | Nein | — |
wastedPropWrites | number | Nein | Prop writes of the value the view already had. |
layoutPasses | number | Nein | Layouts that computed at least one node. |
wastedLayoutPasses | number | Nein | Layout passes after which no box changed. |
nodesLaidOut | number | Nein | Nodes the engine computed rather than took from its cache. |
nodesFramed | number | Nein | Boxes the renderer took from a pass. |
wastedFrames | number | Nein | Boxes taken unchanged. |
measureCalls | number | Nein | Leaves measured: each one a miss of the engine's measure cache. |
wastedMeasures | number | Nein | Measures that answered what the leaf measured before it was marked dirty. |
uiEntries | number | Nein | Calls into the UI-thread kernel: operations received, events, frames. |
wastedUiEntries | number | Nein | Events the UI-thread kernel had no handler for. |
viewsCreated | number | Nein | Views made with a native view: a flattened node has none. |
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.