#cy.scratch()
// Get all scratch data
cy.scratch(): Record<string, unknown>Read all graph-level scratch data. Namespace extension keys, for example '_myExtension'. Scratch is transient, never exported, and emits no events.
Record<string, unknown>the graph's scratch data object
Example
cy.scratch('title', 'Example graph');console.log(cy.scratch().title); // 'Example graph'#cy.scratch(key)
// Get scratch data by key
cy.scratch(key: string): unknownRead one graph-level scratch data value.
| Name | Description |
|---|---|
key: string | the application field to read or write |
unknownthe value, or undefined when the key is unset
Example
cy.scratch('title', 'Example graph');console.log(cy.scratch('title')); // 'Example graph'#cy.scratch(key, value)
// Set scratch data by key
cy.scratch(key: string, value: unknown): thisWrite one graph-level scratch data value. Scratch writes do not emit events and are never exported.
| Name | Description |
|---|---|
key: string | the application field to read or write |
value: unknown | the value to store |
thisthis core, for chaining
Example
const result = cy.scratch('title', 'Example graph');console.log(result === cy); // true#cy.scratch(patch)
// Set several scratch data fields
cy.scratch(patch: Record<string, unknown>): thisMerge several graph-level scratch data fields. Scratch writes do not emit events and are never exported.
| Name | Description |
|---|---|
patch: Record<string, unknown> | the fields to merge; other fields stay unchanged |
thisthis core, for chaining
Example
cy.scratch({ title: 'Example graph' });console.log(cy.scratch('title')); // 'Example graph'