// Run fn inside a startBatch()/endBatch() pair
cy.batch(fn: () => void): thisRun fn inside a startBatch()/endBatch() pair. The batch closes even if fn throws, so this is the form to prefer. As the outermost pair it is one transaction, batchstart … batchend; there is no rollback, so a throwing fn still ends in batchend, with the mutations that landed before the throw.
| Name | Description |
|---|---|
fn: () => void | the mutations to batch; its return value is discarded |
Returns
thisthis core, for chaining
Example
cy.batch(() => { cy.nodes().unselect(); cy.getElementById('a').select(); });console.log(cy.getElementById('a').selected()); // true