cypress-bootstrap
Version:
Cypress Bootstrap is a project scaffolding tool that sets up a Cypress automation framework with a standardized folder structure and Page Object Model (POM) design. It helps teams quickly start testing with built-in best practices and sample specs.
31 lines (28 loc) • 1.16 kB
text/typescript
import { apiEndpoints } from '../../testbase/apiEndpoints';
import { HttpMethod, StatusCodes } from '../../support/Enums';
import { CustomerResponses } from '../../testbase/modals/responses/CustomerResponses';
describe('Customer API Test Suite', () => {
it('Get all customers', { tags: ['@customers', '@smoke'] }, () => {
cy.sendApiRequest(apiEndpoints.customers, HttpMethod.GET, 'null', StatusCodes.OK).then(
response => {
expect(response).to.be.an('array');
expect(response).to.have.length.greaterThan(0);
Cypress.env('customerId', response[0].id);
}
);
});
it('Get customer by Id', { tags: ['@customers', '@smoke'] }, () => {
cy.sendApiRequest(
apiEndpoints.customerById(Cypress.env('customerId')),
HttpMethod.GET,
'null',
StatusCodes.OK
).then(response => {
const responseBody = response as CustomerResponses.CustomerResponse;
expect(responseBody).to.have.property('id');
expect(responseBody.id).to.eq(Cypress.env('customerId'));
expect(responseBody).to.have.property('name');
expect(responseBody).to.have.property('email');
});
});
});