-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { defineConfig } = require("cypress"); | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
|
||
describe('API Tests', () => { | ||
|
||
it('List Users', () => { | ||
cy.request('GET','https://reqres.in/api/users?page=2') | ||
.then((response) => { | ||
|
||
expect(response.status).to.eq(200); | ||
expect(response.body.page).to.eq(2); | ||
expect(response.body.per_page).to.eq(6); | ||
expect(response.body.total).to.eq(12); | ||
expect(response.body.total_pages).to.eq(2); | ||
expect(response.body.data).to.have.length(6); | ||
|
||
const user = response.body.data[0]; | ||
expect(user).to.have.property('id'); | ||
expect(user).to.have.property('email'); | ||
expect(user).to.have.property('first_name'); | ||
expect(user).to.have.property('last_name'); | ||
expect(user).to.have.property('avatar'); | ||
}); | ||
}); | ||
|
||
it('Signle User', () => { | ||
cy.request('GET','https://reqres.in/api/users/2') | ||
.then((response) => { | ||
expect(response.status).to.eq(200); | ||
|
||
const user = response.body.data; | ||
expect(user).to.have.property('id'); | ||
expect(user).to.have.property('email'); | ||
expect(user).to.have.property('first_name'); | ||
expect(user).to.have.property('last_name'); | ||
expect(user).to.have.property('avatar'); | ||
|
||
const support = response.body.support; | ||
expect(support).to.have.property('url'); | ||
expect(support).to.have.property('text'); | ||
}); | ||
}); | ||
|
||
it('Signle User not found', () => { | ||
cy.request({ | ||
method: 'GET', | ||
url: 'https://reqres.in/api/users/23', | ||
failOnStatusCode: false | ||
}) | ||
.then((response) => { | ||
expect(response.status).to.eq(404); | ||
}); | ||
}); | ||
|
||
|
||
it('List <resource>', () => { | ||
cy.request('GET','https://reqres.in/api/unknown') | ||
.then((response) => { | ||
|
||
expect(response.status).to.eq(200); | ||
expect(response.body.page).to.eq(1); | ||
expect(response.body.per_page).to.eq(6); | ||
expect(response.body.total).to.eq(12); | ||
expect(response.body.total_pages).to.eq(2); | ||
expect(response.body.data).to.have.length(6); | ||
|
||
const user = response.body.data[0]; | ||
expect(user).to.have.property('id'); | ||
expect(user).to.have.property('name'); | ||
expect(user).to.have.property('year'); | ||
expect(user).to.have.property('color'); | ||
expect(user).to.have.property('pantone_value'); | ||
}); | ||
}); | ||
|
||
it('Single <resource>', () => { | ||
cy.request('GET','https://reqres.in/api/unknown/2') | ||
.then((response) => { | ||
|
||
expect(response.status).to.eq(200); | ||
|
||
const user = response.body.data; | ||
expect(user).to.have.property('id'); | ||
expect(user).to.have.property('name'); | ||
expect(user).to.have.property('year'); | ||
expect(user).to.have.property('color'); | ||
expect(user).to.have.property('pantone_value'); | ||
|
||
const support = response.body.support; | ||
expect(support).to.have.property('url'); | ||
expect(support).to.have.property('text'); | ||
}); | ||
}); | ||
|
||
it('Signle <resource> not found', () => { | ||
cy.request({ | ||
method: 'GET', | ||
url: 'https://reqres.in/api/users/23', | ||
failOnStatusCode: false | ||
}) | ||
.then((response) => { | ||
expect(response.status).to.eq(404); | ||
}); | ||
}); | ||
|
||
it('Create user', ()=>{ | ||
cy.request('POST', 'https://reqres.in/api/users', { | ||
name: 'Rubaiyat E Mohammad', | ||
job: 'Web Developer', | ||
}).then((response)=>{ | ||
expect(response.status).to.eq(201); | ||
}) | ||
}) | ||
|
||
it('Update user', ()=>{ | ||
cy.request('PUT', 'https://reqres.in/api/users/2', { | ||
name: 'RubaiyatEM', | ||
job: 'Software Developer', | ||
}).then((response)=>{ | ||
expect(response.status).to.eq(200); | ||
}) | ||
}) | ||
|
||
it('Patch user', ()=>{ | ||
cy.request('PATCH', 'https://reqres.in/api/users/2', { | ||
name: 'Rubaiyat E M', | ||
job: 'Dev Ops', | ||
}).then((response)=>{ | ||
expect(response.status).to.eq(200); | ||
}) | ||
}) | ||
|
||
it('Delete user', () => { | ||
cy.request('DELETE', 'https://reqres.in/api/users/2') | ||
.then((response) => { | ||
expect(response.status).to.eq(204); | ||
}); | ||
}); | ||
|
||
it('Delayed response', () => { | ||
cy.request('GET','https://reqres.in/api/users?delay=3') | ||
.then((response) => { | ||
|
||
expect(response.status).to.eq(200); | ||
expect(response.body.page).to.eq(1); | ||
expect(response.body.per_page).to.eq(6); | ||
expect(response.body.total).to.eq(12); | ||
expect(response.body.total_pages).to.eq(2); | ||
expect(response.body.data).to.have.length(6); | ||
|
||
const user = response.body.data[0]; | ||
expect(user).to.have.property('id'); | ||
expect(user).to.have.property('email'); | ||
expect(user).to.have.property('first_name'); | ||
expect(user).to.have.property('last_name'); | ||
expect(user).to.have.property('avatar'); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
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) => { ... }) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/e2e.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') |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.