// Count visible nodes and edges at each level of detail in the current viewport
cy.viewportCounts(): Promise<ViewportCounts | null>Count visible nodes and edges at each level of detail in the current viewport. Resolves after the renderer computes the counts for a frame. Resolves null when headless, destroyed, or when the device is lost before that frame completes.
For synchronous geometric containment, use elementsInBox() with the bounds returned by extent(). That query includes elements regardless of whether they are large enough to draw.
Promise<ViewportCounts | null>{ nodes, edges } for the next frame drawn, or null
Example
// A headless core has no rendered frame to count.console.log(await cy.viewportCounts()); // null