{"__v":0,"_id":"5697f9a73503e40d0061f4e1","category":{"__v":50,"_id":"5697efe48d2a770d00d2fd16","pages":["5697f9021c4dc823005426a7","5697f9a7d231880d00676f88","5697f9a72cf4060d004eaa98","5697f9a71c4dc823005426a9","5697f9a82cf4060d004eaa99","5697f9a82cf4060d004eaa9a","5697f9a81c4dc823005426aa","5697f9a869393517000c8451","5697f9a73503e40d0061f4e1","5697f9a869393517000c8452","5697f9a92cf4060d004eaa9b","5697f9a88560a60d00e2c398","5697f9a81c4dc823005426ab","5697fe158560a60d00e2c3a6","5697fe15d231880d00676f8e","56995ac8cb127f0d003cc165","56995ac854d7db17000ee9e5","56995ac8113a901900ef8f78","56995ac8113a901900ef8f77","56a0ff2a8b2e6f0d0018e94b","56ab8b29c159aa0d0070de3d","56ab8b290b9e0b0d00616230","56ab8b294e8ba20d006a2377","56ab8b2935138c0d005c944e","56ab8b2af25f160d00e17ef8","56ab8b624e4b730d009eb09e","56ab8b62f25f160d00e17ef9","56ab8b62d4432d1900eed1b0","56ab8b62678b58170031ebb2","56ab8b62678b58170031ebb1","56ab8bf435138c0d005c9450","56ab8bf44e4b730d009eb0a1","56ab8bf435138c0d005c9451","56ab8bf5f9757e0d007c65e7","56ab8bf58beeff0d003b809a","56ab8c3ef25f160d00e17efc","56ab8c3f4e8ba20d006a237a","56ab8c3f8beeff0d003b809b","56ab8c3f4e4b730d009eb0a2","56ab8c3f0b9e0b0d00616234","56ab8c704e4b730d009eb0a3","56ab8c709327b30d00f7c1f1","56ab8c714e8ba20d006a237c","56ab8c71f9757e0d007c65e9","56ab8c71f9757e0d007c65ea","56ab8ce8678b58170031ebbd","56ab8ce78beeff0d003b809d","56ab8ce70b9e0b0d00616237","56ab8ce84e4b730d009eb0a4","56ab8ce84e8ba20d006a237d"],"project":"568fde81b700ce0d002f4b43","version":"568fde82b700ce0d002f4b46","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-14T18:58:44.771Z","from_sync":false,"order":3,"slug":"cypress-api","title":"Cypress API"},"parentDoc":null,"project":"568fde81b700ce0d002f4b43","user":"568fffce769f210d0013258f","version":{"__v":23,"_id":"568fde82b700ce0d002f4b46","project":"568fde81b700ce0d002f4b43","createdAt":"2016-01-08T16:06:26.373Z","releaseDate":"2016-01-08T16:06:26.373Z","categories":["568fde82b700ce0d002f4b47","568ff0e504440a1700e4cbbd","569002f19ebef90d0087289d","569004f4769f210d00132599","5690056d9ebef90d008728a0","569005d394c5030d0028813a","5690067804440a1700e4cbe2","569137eb3c4f510d00ec9b92","56913815e56a790d008dbfe3","569138ba3c4f510d00ec9b93","5691392f3c4f510d00ec9b94","56913bbe72f2810d007e4cb0","56933b8d6ebadc0d005b71d2","56933b8d6ebadc0d005b71d3","569564facaa32519009c41e6","5696a319b6d61f0d00acfb40","5696a319a857080d0082e8e8","5697efe43503e40d0061f4d1","5697efe48d2a770d00d2fd16","569e9597ffccd10d00a05c59","56a7a1523d33bc2100793d5c","56a7a32ecf6d771700baeee8","56b8b0f7ddeb231700e69825"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"bar","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-14T19:40:23.996Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"`Cypress.config` allows you to `get` and `set` your configuration options.\n\nThis document covers the API for consuming your configuration options *in your tests*.\n\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"[Read about configuration first.](https://on.cypress.io/guides/configuration)\",\n  \"title\": \"New to Cypress?\"\n}\n[/block]\n\n# [Cypress.config()](#section-no-arguments-usage)\n\nReturns all of your configuration options as an object literal.\n\n***\n\n# [Cypress.config( *key* )](#section-key-usage)\n\nReturns the value of a single configuration option by its key.\n\n***\n\n# [Cypress.config( *key*, *value* )](#section-key-value-usage)\n\nSets a configuration option for a specific key.\n\n***\n\n# [Cypress.config( *object* )](#section-object-usage)\n\nSets multiple configuration options.\n\n***\n\n# No Arguments Usage\n\n## Get all configuration options.\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"// cypress.json\\n{\\n  \\\"defaultCommandTimeout\\\": 10000\\n}\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"Cypress.config() // => {defaultCommandTimeout: 10000, pageLoadTimeout: 30000, ...}\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\n***\n\n# Key Usage\n\n## Return just a single configuration option value.\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"// cypress.json\\n{\\n  \\\"pageLoadTimeout\\\": 60000\\n}\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"Cypress.config(\\\"pageLoadTimeout\\\") // => 60000\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\n***\n\n# Key Value Usage\n\n## Cypress allows you to change the values of your configuration options from within your tests.\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Any value you change will be permanently changed for the remainder of your tests.\"\n}\n[/block]\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"// cypress.json\\n{\\n  \\\"viewportWidth\\\": 1280,\\n  \\\"viewportHeight\\\": 720\\n}\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"Cypress.config(\\\"viewportWidth\\\", 800)\\n\\nCypress.config(\\\"viewportWidth\\\") // => 800\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\n***\n\n# Object Usage\n\n## You can set multiple values by passing an object literal.\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"// cypress.json\\n{\\n  \\\"defaultCommandTimeout\\\": 4000,\\n  \\\"pageLoadTimeout\\\": 30000,\\n}\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"Cypress.config({\\n  defaultCommandTimeout: 10000,\\n  viewportHeight: 900\\n})\\n\\nCypress.config() // => {defaultCommandTimeout: 10000, viewportHeight: 900, ...}\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\n***\n\n# Notes\n\n## Why use `Cypress.config` instead of `cy.config`?\n\nAs a rule of thumb anything you call from `Cypress` affects global state. Anything you call from `cy` affects local state.\n\nMethods on `cy` are local and specific to a single test. Side effects from `cy` methods are restored between each test. We chose to use `Cypress` because changes to your configuration options take effect for the remainder of **ALL** tests.","excerpt":"get and set configuration options","slug":"config","type":"basic","title":"config"}

config

get and set configuration options

`Cypress.config` allows you to `get` and `set` your configuration options. This document covers the API for consuming your configuration options *in your tests*. [block:callout] { "type": "info", "body": "[Read about configuration first.](https://on.cypress.io/guides/configuration)", "title": "New to Cypress?" } [/block] # [Cypress.config()](#section-no-arguments-usage) Returns all of your configuration options as an object literal. *** # [Cypress.config( *key* )](#section-key-usage) Returns the value of a single configuration option by its key. *** # [Cypress.config( *key*, *value* )](#section-key-value-usage) Sets a configuration option for a specific key. *** # [Cypress.config( *object* )](#section-object-usage) Sets multiple configuration options. *** # No Arguments Usage ## Get all configuration options. [block:code] { "codes": [ { "code": "// cypress.json\n{\n \"defaultCommandTimeout\": 10000\n}\n", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "Cypress.config() // => {defaultCommandTimeout: 10000, pageLoadTimeout: 30000, ...}\n", "language": "javascript" } ] } [/block] *** # Key Usage ## Return just a single configuration option value. [block:code] { "codes": [ { "code": "// cypress.json\n{\n \"pageLoadTimeout\": 60000\n}\n", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "Cypress.config(\"pageLoadTimeout\") // => 60000\n", "language": "javascript" } ] } [/block] *** # Key Value Usage ## Cypress allows you to change the values of your configuration options from within your tests. [block:callout] { "type": "warning", "body": "Any value you change will be permanently changed for the remainder of your tests." } [/block] [block:code] { "codes": [ { "code": "// cypress.json\n{\n \"viewportWidth\": 1280,\n \"viewportHeight\": 720\n}\n", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "Cypress.config(\"viewportWidth\", 800)\n\nCypress.config(\"viewportWidth\") // => 800\n", "language": "javascript" } ] } [/block] *** # Object Usage ## You can set multiple values by passing an object literal. [block:code] { "codes": [ { "code": "// cypress.json\n{\n \"defaultCommandTimeout\": 4000,\n \"pageLoadTimeout\": 30000,\n}\n", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "Cypress.config({\n defaultCommandTimeout: 10000,\n viewportHeight: 900\n})\n\nCypress.config() // => {defaultCommandTimeout: 10000, viewportHeight: 900, ...}\n", "language": "javascript" } ] } [/block] *** # Notes ## Why use `Cypress.config` instead of `cy.config`? As a rule of thumb anything you call from `Cypress` affects global state. Anything you call from `cy` affects local state. Methods on `cy` are local and specific to a single test. Side effects from `cy` methods are restored between each test. We chose to use `Cypress` because changes to your configuration options take effect for the remainder of **ALL** tests.