Files
cypress/docs/source/api/cypress-api/cypress-server.md
T
2017-07-04 21:39:59 -04:00

1.3 KiB

title, comments
title comments
Cypress.Server false

Permanently change the default options for all {% url cy.server() server %} instances

{% note info New to Cypress? %} Any configuration you pass to {% url cy.server() server %} will only persist until the end of the test. {% endnote %}

Syntax

Cypress.Server.defaults(options)

Usage

{% fa fa-check-circle green %} Correct Usage

Cypress.Server.defaults({}) // Set server defaults

{% fa fa-exclamation-triangle red %} Incorrect Usage

cy.Server.defaults({})  // Errors, cannot be chained off 'cy'

Arguments

{% fa fa-angle-right %} options (Object)

Pass in an options object to change the default behavior of .filter().

Examples

Options

These options will be the new defaults.

// pass anything here you'd normally pass to cy.server().
Cypress.Server.defaults({
  delay: 500,
  force404: false,
  whitelist: function(xhr){
    // handle custom logic for whitelisting
  }
})

Notes

Where to put server configuration

A great place to put this configuration is in your cypress/support/defaults.js file, since it is loaded before any test files are evaluated.

See also

  • {% url cy.server() server %}