test v1
This commit is contained in:
57
cypress/e2e/Example/todo.cy.js
Normal file
57
cypress/e2e/Example/todo.cy.js
Normal file
@@ -0,0 +1,57 @@
|
||||
const login = require("../../fixtures/login");
|
||||
|
||||
context("Login and buy stuff", () => {
|
||||
before(() => {
|
||||
cy.visit('/');
|
||||
});
|
||||
describe("Attempt to sign in", () => {
|
||||
it('should have link to sign in', () => {
|
||||
cy.get('[data-cy=signInBtn]').click();
|
||||
});
|
||||
|
||||
it("Type data and submit form", () => {
|
||||
cy.get('[data-cy=email]')
|
||||
.type(login.email)
|
||||
.should("have.value", login.email);
|
||||
|
||||
cy.get('[data-cy=password]')
|
||||
.type(login.password)
|
||||
.should("have.value", login.password);
|
||||
|
||||
cy.get('[data-cy=submit]').click();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Buy stuff process", () => {
|
||||
it('url should be /shop', () => {
|
||||
cy.url().should("include", "/shop");
|
||||
});
|
||||
|
||||
it('check the cart to be zero', () => {
|
||||
cy.get('[data-cy=cart]').contains(0);
|
||||
})
|
||||
|
||||
it('click on stuff 2', () => {
|
||||
cy.get('[data-cy=stuff-1]').contains('Add');
|
||||
cy.get('[data-cy=stuff-1]').click();
|
||||
});
|
||||
|
||||
it('increment the cart', () => {
|
||||
cy.get('[data-cy=cart]').contains(1);
|
||||
})
|
||||
|
||||
it('click on cart', () => {
|
||||
cy.get('[data-cy=cart]').click();
|
||||
});
|
||||
|
||||
it('redirect to cart view', () => {
|
||||
cy.url().should("include", "/cart");
|
||||
});
|
||||
|
||||
it('purchase stuff and see confirm message', () => {
|
||||
cy.get('[data-cy=submit]').contains('PURCHASE');
|
||||
cy.get('[data-cy=submit]').click();
|
||||
cy.get('[data-cy=success]').contains('Thank you for your purchase');
|
||||
});
|
||||
})
|
||||
});
|
||||
13
cypress/e2e/Pokedemo/app-component.cy.js
Normal file
13
cypress/e2e/Pokedemo/app-component.cy.js
Normal file
@@ -0,0 +1,13 @@
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('http://localhost:4200')
|
||||
})
|
||||
|
||||
it('should display title', () => {
|
||||
cy.get('h1').should('contain', 'pokedemo!')
|
||||
})
|
||||
|
||||
it('should load the page', () => {
|
||||
cy.get('app-root').should('exist')
|
||||
})
|
||||
})
|
||||
5
cypress/fixtures/example.json
Normal file
5
cypress/fixtures/example.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
37
cypress/support/commands.ts
Normal file
37
cypress/support/commands.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************
|
||||
// This example commands.ts shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
//
|
||||
// declare global {
|
||||
// namespace Cypress {
|
||||
// interface Chainable {
|
||||
// login(email: string, password: string): Chainable<void>
|
||||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
||||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
||||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
17
cypress/support/e2e.ts
Normal file
17
cypress/support/e2e.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// ***********************************************************
|
||||
// This example support/e2e.ts is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands'
|
||||
Reference in New Issue
Block a user