Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rafaelfgx/cypress
Cypress.
https://github.com/rafaelfgx/cypress
cypress cypress-io cypress-tests test test-automation testing tests
Last synced: 3 days ago
JSON representation
Cypress.
- Host: GitHub
- URL: https://github.com/rafaelfgx/cypress
- Owner: rafaelfgx
- License: mit
- Created: 2021-03-19T23:19:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-21T15:21:39.000Z (4 months ago)
- Last Synced: 2024-07-21T16:59:12.401Z (4 months ago)
- Topics: cypress, cypress-io, cypress-tests, test, test-automation, testing, tests
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Cypress
## Links
* [Cypress](https://cypress.io)
* [Cypress Examples](https://example.cypress.io)
* [Joi](https://joi.dev)## Run
1. Execute **npm i**
2. Execute **npm run cy:open** or **npm run cy:run**## Examples
### Functions
```js
const add = (a, b) => a + bconst subtract = (a, b) => a - b
const divide = (a, b) => a / b
const multiply = (a, b) => a * b
``````js
describe("Math", () => {
it("Add", () => expect(add(5, 10)).to.eq(15))it("Subtract", () => expect(subtract(15, 5)).to.eq(10))
it("Divide", () => expect(divide(10, 2)).to.eq(5))
it("Divide by Zero", () => expect(divide(10, 0)).to.eq(Infinity))
it("Multiply", () => expect(multiply(2, 5)).to.eq(10))
})
```### API
```js
const url = "https://jsonplaceholder.cypress.io"describe("API", () => {
describe("Users", () => {
it("Status 200", () => cy.request(`${url}/users`).its("status").should("eq", 200))
})describe("Todos", () => {
it("Status 200", () => cy.request(`${url}/todos`).its("status").should("eq", 200))it("Valid", () => {
const schema = JOI.array().items(JOI.object({
id: JOI.number(),
title: JOI.string(),
completed: JOI.bool(),
userId: JOI.number()
}))cy.request(`${url}/todos`).should((response) => JOI.assert(response.body, schema))
})
})
})
```### Browser
```js
describe("Browser", () => {
describe("Login", () => {
beforeEach(() => cy.visit("https://practicetestautomation.com/practice-test-login"))it("Invalid", () => {
cy.get("input[name='username']").type("invalid")
cy.get("input[name='password']").type("invalid")
cy.get("button[id='submit']").click()
cy.get("div#error").should("be.visible")
})it("Valid", () => {
cy.get("input[name='username']").type("student")
cy.get("input[name='password']").type("Password123")
cy.get("button[id='submit']").click()
cy.url().should("contain", "logged-in-successfully")
})
})
})
```