cypress-example-kitchensink
Advanced tools
Comparing version 1.12.0 to 1.13.0
@@ -137,5 +137,5 @@ /* global hljs, $ */ | ||
data: { | ||
name: 'Using POST in cy.route()', | ||
name: 'Using POST in cy.intercept()', | ||
email: 'hello@cypress.io', | ||
body: 'You can change the method used for cy.route() to be GET, POST, PUT, PATCH, or DELETE', | ||
body: 'You can change the method used for cy.intercept() to be GET, POST, PUT, PATCH, or DELETE', | ||
}, | ||
@@ -152,5 +152,5 @@ }).then(() => { | ||
data: { | ||
name: 'Using PUT in cy.route()', | ||
name: 'Using PUT in cy.intercept()', | ||
email: 'hello@cypress.io', | ||
body: 'You can change the method used for cy.route() to be GET, POST, PUT, PATCH, or DELETE', | ||
body: 'You can change the method used for cy.intercept() to be GET, POST, PUT, PATCH, or DELETE', | ||
}, | ||
@@ -157,0 +157,0 @@ statusCode: { |
@@ -30,4 +30,3 @@ /// <reference types="cypress" /> | ||
// Alias the route to wait for its response | ||
cy.server() | ||
cy.route('GET', 'comments/*').as('getComment') | ||
cy.intercept('GET', '**/comments/*').as('getComment') | ||
@@ -39,4 +38,4 @@ // we have code that gets a comment when | ||
// https://on.cypress.io/wait | ||
cy.wait('@getComment').its('status').should('eq', 200) | ||
cy.wait('@getComment').its('response.statusCode').should('eq', 200) | ||
}) | ||
}) |
@@ -68,8 +68,5 @@ /// <reference types="cypress" /> | ||
it('.defaults() - set defaults for all cookies', () => { | ||
if (Number(Cypress.version.charAt(0)) < 5) return | ||
// now any cookie with the name 'session_id' will | ||
// not be cleared before each new test runs | ||
Cypress.Cookies.defaults({ | ||
// @ts-ignore | ||
preserve: 'session_id', | ||
@@ -80,19 +77,2 @@ }) | ||
context('Cypress.Server', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:8080/cypress-api') | ||
}) | ||
// Permanently override server options for | ||
// all instances of cy.server() | ||
// https://on.cypress.io/cypress-server | ||
it('.defaults() - change default config of server', () => { | ||
Cypress.Server.defaults({ | ||
delay: 0, | ||
force404: false, | ||
}) | ||
}) | ||
}) | ||
context('Cypress.arch', () => { | ||
@@ -99,0 +79,0 @@ beforeEach(() => { |
@@ -25,8 +25,5 @@ /// <reference types="cypress" /> | ||
cy.server() | ||
cy.fixture('example.json').as('comment') | ||
// when application makes an Ajax request matching "GET comments/*" | ||
// Cypress will intercept it and reply with object | ||
// from the "comment" alias | ||
cy.route('GET', 'comments/*', '@comment').as('getComment') | ||
// when application makes an Ajax request matching "GET **/comments/*" | ||
// Cypress will intercept it and reply with the object in `example.json` fixture | ||
cy.intercept('GET', '**/comments/*', { fixture: 'example.json' }).as('getComment') | ||
@@ -37,28 +34,5 @@ // we have code that gets a comment when | ||
cy.wait('@getComment').its('responseBody') | ||
cy.wait('@getComment').its('response.body') | ||
.should('have.property', 'name') | ||
.and('include', 'Using fixtures to represent data') | ||
// you can also just write the fixture in the route | ||
cy.route('GET', 'comments/*', 'fixture:example.json').as('getComment') | ||
// we have code that gets a comment when | ||
// the button is clicked in scripts.js | ||
cy.get('.fixture-btn').click() | ||
cy.wait('@getComment').its('responseBody') | ||
.should('have.property', 'name') | ||
.and('include', 'Using fixtures to represent data') | ||
// or write fx to represent fixture | ||
// by default it assumes it's .json | ||
cy.route('GET', 'comments/*', 'fx:example').as('getComment') | ||
// we have code that gets a comment when | ||
// the button is clicked in scripts.js | ||
cy.get('.fixture-btn').click() | ||
cy.wait('@getComment').its('responseBody') | ||
.should('have.property', 'name') | ||
.and('include', 'Using fixtures to represent data') | ||
}) | ||
@@ -65,0 +39,0 @@ |
@@ -8,46 +8,4 @@ /// <reference types="cypress" /> | ||
// Manage AJAX / XHR requests in your app | ||
// Manage HTTP requests in your app | ||
it('cy.server() - control behavior of network requests and responses', () => { | ||
// https://on.cypress.io/server | ||
cy.server().should((server) => { | ||
// the default options on server | ||
// you can override any of these options | ||
expect(server.delay).to.eq(0) | ||
expect(server.method).to.eq('GET') | ||
expect(server.status).to.eq(200) | ||
expect(server.headers).to.be.null | ||
expect(server.response).to.be.null | ||
expect(server.onRequest).to.be.undefined | ||
expect(server.onResponse).to.be.undefined | ||
expect(server.onAbort).to.be.undefined | ||
// These options control the server behavior | ||
// affecting all requests | ||
// pass false to disable existing route stubs | ||
expect(server.enable).to.be.true | ||
// forces requests that don't match your routes to 404 | ||
expect(server.force404).to.be.false | ||
if (Number(Cypress.version.charAt(0)) >= 5) { | ||
// ignores requests from ever being logged or stubbed | ||
// @ts-ignore | ||
expect(server.ignore).to.be.a('function') | ||
} | ||
}) | ||
cy.server({ | ||
method: 'POST', | ||
delay: 1000, | ||
status: 422, | ||
response: {}, | ||
}) | ||
// any route commands will now inherit the above options | ||
// from the server. anything we pass specifically | ||
// to route will override the defaults though. | ||
}) | ||
it('cy.request() - make an XHR request', () => { | ||
@@ -159,11 +117,9 @@ // https://on.cypress.io/request | ||
it('cy.route() - route responses to matching requests', () => { | ||
// https://on.cypress.io/route | ||
it('cy.intercept() - route responses to matching requests', () => { | ||
// https://on.cypress.io/http | ||
let message = 'whoa, this comment does not exist' | ||
cy.server() | ||
// Listen to GET to comments/1 | ||
cy.route('GET', 'comments/*').as('getComment') | ||
cy.intercept('GET', '**/comments/*').as('getComment') | ||
@@ -175,6 +131,6 @@ // we have code that gets a comment when | ||
// https://on.cypress.io/wait | ||
cy.wait('@getComment').its('status').should('eq', 200) | ||
cy.wait('@getComment').its('response.statusCode').should('be.oneOf', [200, 304]) | ||
// Listen to POST to comments | ||
cy.route('POST', '/comments').as('postComment') | ||
cy.intercept('POST', '**/comments').as('postComment') | ||
@@ -184,15 +140,17 @@ // we have code that posts a comment when | ||
cy.get('.network-post').click() | ||
cy.wait('@postComment').should((xhr) => { | ||
expect(xhr.requestBody).to.include('email') | ||
expect(xhr.requestHeaders).to.have.property('Content-Type') | ||
expect(xhr.responseBody).to.have.property('name', 'Using POST in cy.route()') | ||
cy.wait('@postComment').should(({ request, response }) => { | ||
expect(request.body).to.include('email') | ||
expect(request.headers).to.have.property('content-type') | ||
expect(response && response.body).to.have.property('name', 'Using POST in cy.intercept()') | ||
}) | ||
// Stub a response to PUT comments/ **** | ||
cy.route({ | ||
cy.intercept({ | ||
method: 'PUT', | ||
url: 'comments/*', | ||
status: 404, | ||
response: { error: message }, | ||
delay: 500, | ||
url: '**/comments/*', | ||
}, { | ||
statusCode: 404, | ||
body: { error: message }, | ||
headers: { 'access-control-allow-origin': '*' }, | ||
delayMs: 500, | ||
}).as('putComment') | ||
@@ -199,0 +157,0 @@ |
@@ -21,6 +21,4 @@ /// <reference types="cypress" /> | ||
it('cy.wait() - wait for a specific route', () => { | ||
cy.server() | ||
// Listen to GET to comments/1 | ||
cy.route('GET', 'comments/*').as('getComment') | ||
cy.intercept('GET', '**/comments/*').as('getComment') | ||
@@ -32,4 +30,4 @@ // we have code that gets a comment when | ||
// wait for GET comments/1 | ||
cy.wait('@getComment').its('status').should('eq', 200) | ||
cy.wait('@getComment').its('response.statusCode').should('be.oneOf', [200, 304]) | ||
}) | ||
}) |
{ | ||
"name": "cypress-example-kitchensink", | ||
"version": "1.12.0", | ||
"version": "1.13.0", | ||
"description": "This is an example app used to showcase Cypress.io testing. For a full reference of our documentation, go to https://docs.cypress.io", | ||
@@ -69,3 +69,3 @@ "main": "index.js", | ||
"colon-names": "1.0.0", | ||
"cypress": "4.12.1", | ||
"cypress": "5.0.0", | ||
"eslint": "7.0.0", | ||
@@ -72,0 +72,0 @@ "eslint-plugin-cypress": "2.8.1", |
@@ -25,3 +25,3 @@ # Kitchen Sink [![renovate-app badge][renovate-badge]][renovate-app] [![semantic-release][semantic-image] ][semantic-url] | ||
Buildkite | | [.buildkite/pipeline.yml](.buildkite/pipeline.yml) | ||
Circle | [![CircleCI](https://circleci.com/gh/cypress-io/cypress-example-kitchensink/tree/master.svg?style=svg)](https://circleci.com/gh/cypress-io/cypress-example-kitchensink/tree/master) | [basic/circle.yml](basic/circle.yml) | [circle.yml](circle.yml) | ||
Circle | [![CircleCI](https://circleci.com/gh/cypress-io/cypress-example-kitchensink/tree/master.svg?style=svg)](https://circleci.com/gh/cypress-io/cypress-example-kitchensink/tree/master) | [basic/.circleci/config.yml](basic/.circleci/config.yml) | [.circleci/config.yml](.circleci/config.yml) | ||
Codeship Pro | [ ![Codeship Pro CI](https://app.codeship.com/projects/8d6a20c0-b70e-0133-41c6-56e5cd60fbd0/status?branch=master)](https://app.codeship.com/projects/134609) | [basic/codeship-pro](basic/codeship-pro) | ||
@@ -28,0 +28,0 @@ GitHub Actions | [![Parallel tests status](https://github.com/cypress-io/cypress-example-kitchensink/workflows/Cypress%20parallel%20tests/badge.svg?branch=master)](https://github.com/cypress-io/cypress-example-kitchensink/actions) | [single.yml](.github/workflows/single.yml) | [parallel.yml](.github/workflows/parallel.yml) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2286912
3200