-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
101fc83
commit b30635a
Showing
2 changed files
with
101 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,75 @@ | ||
// describe and it are comming from Mocha | ||
// expect is comming form Chai | ||
|
||
// you can add this line Triple slash directives | ||
// to activate IntelliSense | ||
// /// <reference types="Cypress" /> | ||
// or you can add the file jsconfig.json | ||
|
||
describe("First Test", () => { | ||
it("Does not do much!", () => { | ||
expect(true).to.not.equal(false); | ||
}); | ||
|
||
it("App should have a class called App-header", () => { | ||
// visit the home page | ||
// the baseUrl configured in cypress.json file | ||
cy.visit("/"); | ||
// check for the existance of the elment using his class name | ||
cy.get(".App").should("exist"); | ||
}); | ||
|
||
it("should calculate the two numbers entered by the user", () => { | ||
cy.visit("/"); | ||
cy.get(".App-header").should("exist"); | ||
|
||
/* | ||
get the element contains the word Sum | ||
in our case it's the buttom | ||
the button should be disabled | ||
*/ | ||
cy.contains("Sum").should("be.disabled"); | ||
|
||
// get the element by class name | ||
cy.get(".result").contains("result :"); | ||
|
||
/* | ||
get the input by its id | ||
then simulate the user typing | ||
the number 2 then check if | ||
the input has the value 2 | ||
*/ | ||
cy.get("#num1") | ||
.type(2) | ||
.should("have.value", "2"); | ||
|
||
cy.get("#num2") | ||
.type(2) | ||
.should("have.value", "2"); | ||
|
||
/* | ||
get element bt its type | ||
and check the type of the button | ||
using match and regex | ||
*/ | ||
cy.get("button") | ||
.contains("Sum") | ||
.should("have.attr", "type") | ||
.and("match", /button/); | ||
|
||
// another way of checking the type | ||
cy.contains("Sum") | ||
.should("have.attr", "type", "button") | ||
.should("not.be.disabled"); | ||
|
||
/* | ||
click the button which should sum | ||
the two numbers | ||
*/ | ||
cy.get("button") | ||
.contains("Sum") | ||
.click(); | ||
|
||
// check the result div after clicking the Sum button | ||
cy.get(".result").contains("result : 4"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters