Learn how to add and manage cookies in your Stably tests for user preferences, state management, and cookie-dependent functionality testing.
context.addCookies()
method to add one or more cookies:
Property | Type | Required | Description |
---|---|---|---|
name | string | ✅ | The name of the cookie |
value | string | ✅ | The value of the cookie |
domain | string | ✅ | The domain for which the cookie is valid |
path | string | ❌ | The path for which the cookie is valid (defaults to ’/‘) |
expires | number | ❌ | Expiration time as Unix timestamp in seconds |
httpOnly | boolean | ❌ | Whether the cookie is HTTP-only |
secure | boolean | ❌ | Whether the cookie requires HTTPS |
sameSite | string | ❌ | SameSite attribute (‘Strict’, ‘Lax’, or ‘None’) |