Skip to content

Instantly share code, notes, and snippets.

View LeonardoFassini's full-sized avatar

Leonardo Tironi Fassini LeonardoFassini

View GitHub Profile
beforeEach(function () {
cy.log('I run before every test in every spec file!!!!!!')
})
describe('Hooks', function() {
before(function() {
// runs once before all tests in the block
})
after(function() {
// runs once after all tests in the block
})
beforeEach(function() {
// runs before each test in the block
})
describe('Login Page', function () {
it('should login successfully', function () {
cy.visit('/');
cy.get('[data-test=loginInput]').type('admin');
cy.get('[data-test=passwordInput]').type('timmy');
cy.get('[data-test=submitButton]').click();
cy.url().should('eq', Cypress.env('baseUrl') + '/todo');
});
...
});
cy.visit('localhost:5000/todos');
cy.get('button[type=submit]').click();
cy.get('[data-test=todoItem]')
.its('length')
.should('be.greaterThan', 0);
//You can put a cy.get inside a expect to make assertions.
expect(true).to.be(true);
cy.route('GET', '**/todos/list', 'fixture:todos-list.json');
Feature: Login
I want to log in the application
Scenario: Log in successful
Given I am at the login page
When I type the correct username
And I type the correct password
And I click to log in
Then I should be on the todo page
Feature: Tasting experience
Scenario:
When I put a banana in the bowl
And I put milk
And I taste it
Then The taste should be good
Scenario:
When I put a banana in the bowl