{
  "doc": {
    "id": "api/cypress-api/config",
    "title": "Cypress.config()",
    "description": "Get and set configuration options in your tests.",
    "section": "api",
    "source_path": "/llm/markdown/api/cypress-api/config.md",
    "version": "c4ad6f88c531de58221c73dd91a75af7138334b8",
    "updated_at": "2026-11-10T01:15:02.829Z",
    "headings": [
      {
        "id": "api/cypress-api/config#cypress-config",
        "text": "Cypress.config",
        "level": 1
      },
      {
        "id": "api/cypress-api/config#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/cypress-api/config#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/cypress-api/config#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/cypress-api/config#no-arguments",
        "text": "No Arguments",
        "level": 3
      },
      {
        "id": "api/cypress-api/config#get-all-configuration-options-from-the-cypress-configuration",
        "text": "Get all configuration options from the Cypress configuration",
        "level": 4
      },
      {
        "id": "api/cypress-api/config#name",
        "text": "Name",
        "level": 3
      },
      {
        "id": "api/cypress-api/config#return-a-single-configuration-option-from-the-cypress-configuration",
        "text": "Return a single configuration option from the Cypress configuration",
        "level": 4
      },
      {
        "id": "api/cypress-api/config#name-and-value",
        "text": "Name and Value",
        "level": 3
      },
      {
        "id": "api/cypress-api/config#change-the-values-of-configuration-options-from-the-cypress-configuration-from-within-your-tests",
        "text": "Change the values of configuration options from the Cypress configuration from within your tests",
        "level": 4
      },
      {
        "id": "api/cypress-api/config#object",
        "text": "Object",
        "level": 3
      },
      {
        "id": "api/cypress-api/config#override-multiple-options-from-the-cypress-configuration-by-passing-an-object",
        "text": "Override multiple options from the Cypress configuration by passing an object",
        "level": 4
      },
      {
        "id": "api/cypress-api/config#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/cypress-api/config#not-all-config-values-can-be-changed-at-all-times",
        "text": "Not all config values can be changed at all times",
        "level": 3
      },
      {
        "id": "api/cypress-api/config#test-configuration-vs-cypress-config",
        "text": "Test Configuration vs Cypress.config()",
        "level": 3
      },
      {
        "id": "api/cypress-api/config#cypress-config-executes-synchronously",
        "text": "Cypress.config() executes Synchronously",
        "level": 3
      },
      {
        "id": "api/cypress-api/config#why-is-it-cypress-config-and-not-cy-config",
        "text": "Why is it Cypress.config and not cy.config?",
        "level": 3
      },
      {
        "id": "api/cypress-api/config#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/cypress-api/config#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "content": {
    "type": "root",
    "children": [
      {
        "type": "heading",
        "depth": 1,
        "children": [
          {
            "type": "text",
            "value": "Cypress.config"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`get` and `set` configuration options in your tests."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "New to Cypress?"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md",
            "children": [
              {
                "type": "text",
                "value": "Read about configuration first."
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Scope"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Configuration set using `Cypress.config` is only in scope for the current spec file."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Cypress runs each spec file in isolation: the browser is exited between specs. Configuration changed in one spec won't be visible in other specs."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Note"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Not all configuration values can be changed during runtime. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Notes",
            "children": [
              {
                "type": "text",
                "value": "Notes"
              }
            ]
          },
          {
            "type": "text",
            "value": " below for details."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Syntax"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress.config()\nCypress.config(name)\nCypress.config(name, value)\nCypress.config(object)"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Arguments"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "name (String)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The name of the configuration to get or set."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "value (Any)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The value of the configuration to set."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "object (Object)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Set multiple configuration options with an object literal."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Examples"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "No Arguments"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Get all configuration options from the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md",
            "children": [
              {
                "type": "text",
                "value": "Cypress configuration"
              }
            ]
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.js"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.ts"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const { defineConfig } = require('cypress')\n\nmodule.exports = defineConfig({\n  defaultCommandTimeout: 10000,\n})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "import { defineConfig } from 'cypress'\n\nexport default defineConfig({\n  defaultCommandTimeout: 10000,\n})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress.config() // => {defaultCommandTimeout: 10000, pageLoadTimeout: 30000, ...}"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Name"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Return a single configuration option from the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md",
            "children": [
              {
                "type": "text",
                "value": "Cypress configuration"
              }
            ]
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.js"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.ts"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const { defineConfig } = require('cypress')\n\nmodule.exports = defineConfig({\n  pageLoadTimeout: 60000,\n})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "import { defineConfig } from 'cypress'\n\nexport default defineConfig({\n  pageLoadTimeout: 60000,\n})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress.config('pageLoadTimeout') // => 60000"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Name and Value"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Change the values of configuration options from the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md",
            "children": [
              {
                "type": "text",
                "value": "Cypress configuration"
              }
            ]
          },
          {
            "type": "text",
            "value": " from within your tests"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Scope"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Remember, any changes that you make to configuration using this API will be in effect for the remainder of the tests in the same spec file."
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.js"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.ts"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const { defineConfig } = require('cypress')\n\nmodule.exports = defineConfig({\n  defaultCommandTimeout: 4000,\n})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "import { defineConfig } from 'cypress'\n\nexport default defineConfig({\n  defaultCommandTimeout: 4000,\n})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress.config('defaultCommandTimeout', 10000)\n\nCypress.config('defaultCommandTimeout') // => 10000"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Object"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Override multiple options from the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md",
            "children": [
              {
                "type": "text",
                "value": "Cypress configuration"
              }
            ]
          },
          {
            "type": "text",
            "value": " by passing an object"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.js"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.ts"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const { defineConfig } = require('cypress')\n\nmodule.exports = defineConfig({\n  defaultCommandTimeout: 4000,\n  pageLoadTimeout: 30000,\n})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "import { defineConfig } from 'cypress'\n\nexport default defineConfig({\n  defaultCommandTimeout: 4000,\n  pageLoadTimeout: 30000,\n})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "Cypress.config({\n  defaultCommandTimeout: 10000,\n  pageLoadTimeout: 60000,\n})\n\nCypress.config() // => {defaultCommandTimeout: 10000, pageLoadTimeout: 60000, ...}"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Notes"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Not all config values can be changed at all times"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Some configuration values are readonly and cannot be changed while running a test. Anything that's not directly under Cypress's control - like timeouts or environment variables - will be ignored at run-time. Be sure to review the list of "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md#Test-Configuration",
            "children": [
              {
                "type": "text",
                "value": "test configuration options"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "A few options can be set in a suite or test configuration override, but not with `Cypress.config()` while a test is executing, because doing so would affect the next test rather than the current one. Starting in Cypress "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/changelog.md#16-0-0",
            "children": [
              {
                "type": "text",
                "value": "16.0.0"
              }
            ]
          },
          {
            "type": "text",
            "value": ", `Cypress.config()` throws for these options during test execution:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`blockHosts`"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`viewportHeight` - use "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/viewport.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`cy.viewport()`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " to change the viewport during a test"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`viewportWidth` - use "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/viewport.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`cy.viewport()`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " to change the viewport during a test"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Test Configuration vs `Cypress.config()`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "To apply specific Cypress configuration values to a suite or test, you can pass a "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md#Test-Configuration",
            "children": [
              {
                "type": "text",
                "value": "test configuration"
              }
            ]
          },
          {
            "type": "text",
            "value": " object to the test or suite function."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "While `Cypress.config()` changes configuration values through the entire spec file, using test configuration will only change configuration values during the suite or test where they are set. The values will then reset to the previous default values after the suite or test is complete."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See the full guide on "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md#Test-Configuration",
            "children": [
              {
                "type": "text",
                "value": "test configuration"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "`Cypress.config()` executes Synchronously"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`Cypress.config()` executes synchronously and will not wait for the Cypress commands above it to execute. If you need to update your configuration mid-test, be sure to chain the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/core-concepts/introduction-to-cypress.md#Commands-Are-Asynchronous",
            "children": [
              {
                "type": "text",
                "value": "asynchronously Cypress command"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "it('using cy.then', () => {\n  cy.visit('/my-test_page')\n  cy.click('#download-html').then(() => {\n    Cypress.config('baseUrl', null)\n  })\n  cy.visit('/downloads/contents.html')\n})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Why is it `Cypress.config` and not `cy.config`?"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "As a rule of thumb anything you call from `Cypress` affects global state. Anything you call from `cy` affects local state."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Since the configuration added or changed by `Cypress.config` is only in scope for the current spec file, you'd think that it should be `cy.config` and not `Cypress.config`…and you'd be right. The fact that `Cypress.config` affects local state is an artifact of the API evolving over time: `Cypress.config` used to affect global state—configuration added in one test spec file was available in other specs—but the Cypress team wisely made each spec run in isolation in "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/changelog.md#3-0-0",
            "children": [
              {
                "type": "text",
                "value": "`3.0.0`"
              }
            ]
          },
          {
            "type": "text",
            "value": " and by that time `Cypress.config` was public API."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "History"
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Version"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Changes"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#16-0-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "16.0.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`blockHosts`, `viewportHeight`, and `viewportWidth` can no longer be set with `Cypress.config()` during test execution."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "0.12.6"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`Cypress.config` added"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "See also"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/configuration.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "Cypress configuration"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/guides/environment-variables.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "Environment Variables & Secrets"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/env.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "cy.env()"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " - Command for accessing environment variables"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/cypress-api/expose.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "Cypress.expose()"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " - API for public configuration values"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/configuration.md#Test-Configuration",
                    "children": [
                      {
                        "type": "text",
                        "value": "Test Configuration"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "token_estimate": 1075
}