context('Cypress.platform', () => { beforeEach(() => { cy.visit('https://example.cypress.io/cypress-api') }) it('Get underlying OS name', () => { // https://on.cypress.io/platform expect(Cypress.platform).to.be.exist }) })
function draw() { // Tell program to draw into canvas since img was last created element. context(canvas); noStroke(); background(220, 180, 200); fill(180, 200, 40); strokeWeight(6); stroke(180, 100, 240); for (var i=0; i<width; i+=15) { line(i, 0, i, height); } }
function draw() { // Tell the program to draw into canvas0. context(canvas0); background(120, 180, 200); ellipse(width/2, height/2, 100, 100); // Tell the program to draw into canvas1. context(canvas1); background(50, 120, 80); rect(width/4, height/4, width/2, height/2); // Tell the program to switch back to drawing into canvas0. // context(canvas0); // line(0, 0, width, height); }
context('Cypress.dom', () => { beforeEach(() => { cy.visit('https://example.cypress.io/cypress-api') }) // https://on.cypress.io/dom it('.isHidden() - determine if a DOM element is hidden', () => { let hiddenP = Cypress.$('.dom-p p.hidden').get(0) let visibleP = Cypress.$('.dom-p p.visible').get(0) // our first paragraph has css class 'hidden' expect(Cypress.dom.isHidden(hiddenP)).to.be.true expect(Cypress.dom.isHidden(visibleP)).to.be.false }) })
function draw() { // Tell the program to draw into canvas0. context(canvas0); // Call the method to draw the contents of the canvas. drawEllipseCanvas(); // Tell the program to draw into canvas1. context(canvas1); // Call the method to draw the contents of the canvas. drawRectCanvas(); // Tell the program to draw into canvas2. context(canvas2); // Call the method to draw the contents of the canvas. drawRectCanvas(); }
/// <reference types="Cypress" /> context('Fetch', () => { beforeEach(() => { cy.visit('http://localhost:3001/') }) it('Find dog', () => { cy.get('[data-test=button]').contains('CLICK') cy.get('[data-test=button]').click() cy.get('[data-test=img]').should('be.visible') cy.get('[data-test=button]').click() cy.get('[data-test=img]').should('be.visible') }) })
/// <reference types="Cypress" /> context('Fetch', () => { beforeEach(() => { cy.visit('http://localhost:3001/', { onBeforeLoad (win) { delete win.fetch }, }) }) it('Stub', () => { // Alias the route to wait for its response cy.server() cy.route('GET', '/api/breeds/image/random', { message: 'Intercepted', status: 'success' }) cy.get('[data-test=button]').contains('CLICK') cy.get('[data-test=button]').click() }) })
/// <reference types="Cypress" /> context('Window', () => { beforeEach(() => { cy.visit('https://example.cypress.io/commands/window') }) it('cy.window() - get the global window object', () => { // https://on.cypress.io/window cy.window().should('have.property', 'top') }) it('cy.document() - get the document object', () => { // https://on.cypress.io/document cy.document().should('have.property', 'charset').and('eq', 'UTF-8') }) it('cy.title() - get the title', () => { // https://on.cypress.io/title cy.title().should('include', 'Kitchen Sink') }) })
context('Cypress.arch', () => { beforeEach(() => { cy.visit('https://example.cypress.io/cypress-api') }) it('Get CPU architecture name of underlying OS', () => { // https://on.cypress.io/arch expect(Cypress.arch).to.exist }) })
function draw() { // Tell the program to draw into canvas0. context(canvas0); // Call the method to draw the contents of the canvas. drawEllipseCanvas(); // Try switching in a different function. //drawRectCanvas(); // Tell the program to draw into canvas1. context(canvas1); // Call the method to draw the contents of the canvas. drawRectCanvas(); // Try switching in a different function. //drawEllipseCanvas(); }
context('Cypress.spec', () => { beforeEach(() => { cy.visit('https://example.cypress.io/cypress-api') }) it('Get current spec information', () => { // https://on.cypress.io/spec // wrap the object so we can inspect it easily by clicking in the command log cy.wrap(Cypress.spec).should('have.keys', ['name', 'relative', 'absolute']) }) })
context('Cypress.Server', () => { beforeEach(() => { cy.visit('https://example.cypress.io/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.version', () => { beforeEach(() => { cy.visit('https://example.cypress.io/cypress-api') }) it('Get current version of Cypress being run', () => { // https://on.cypress.io/version expect(Cypress.version).to.be.exist }) })
context('Cypress.log', () => { beforeEach(() => { cy.visit('https://example.cypress.io/cypress-api') }) it('Control what is printed to the Command Log', () => { // https://on.cypress.io/cypress-log }) })
function draw() { // Tell program to draw into canvas since img was last created element. context(canvas); noStroke(); background(220, 180, 200); fill(180, 200, 40); strokeWeight(6); stroke(180, 100, 240); for (var i=0; i<width; i+=15) { line(i, 0, i, height); } }