Skip to content

Commit

Permalink
Adicionando testes cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
HelenLazarotti committed Aug 4, 2023
1 parent eadac97 commit 14f068e
Show file tree
Hide file tree
Showing 10 changed files with 3,522 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -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"
}
19 changes: 19 additions & 0 deletions cypress/integration/weather.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
describe("Weather", () => {
const url = "http://127.0.0.1:5500/index.html";

before(() => {
cy.visit({url})
});

it("Deve escrever nome da cidade no campo de input", () => {
cy.wait(1000);
cy.get('[data-test="city-field"]').type('Arroio do Sal');
cy.get('[data-test="search-button"]').should('exist');
cy.get('[data-test="search-button"]').click();
});


it("Deve aparecer no título, a palavra digitada", () => {
cy.get('[data-test="city-span-field"]').should('have.text', 'Arroio do Sal')
});
})
22 changes: 22 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js 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) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js 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'

// Alternatively you can use CommonJS syntax:
// require('./commands')
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<div class="form">
<h3>Confira o clima de uma cidade:</h3>
<div class="form-input-container">
<input type="text" placeholder="Digite o nome da cidade" id="city-input">
<button id="search">
<input type="text" placeholder="Digite o nome da cidade" id="city-input" data-test="city-field">
<button id="search" data-test="search-button">
<!--Quando tabalho com o font awesome, preciso por sempre:-->
<i class="fa-solid fa-magnifying-glass"></i>
<!--Criou já o campo de search com a lupinha-->
Expand All @@ -27,7 +27,7 @@ <h3>Confira o clima de uma cidade:</h3>
<div id="weather-data" class="hide">
<h2>
<i class="fa-solid fa-location-dot"></i>
<span id="city"></span>
<span id="city" data-test="city-span-field"></span>
<img src="" alt="Bandeira da cidade" id="country">
</h2>

Expand Down
Loading

0 comments on commit 14f068e

Please sign in to comment.