0% found this document useful (0 votes)
6 views

2.Create Sample API Test Script

The document outlines the Cypress request methods for making HTTP calls, including various formats such as cy.request(url) and cy.request(method, url, body). It also describes the Cypress project structure, including folders for tests, fixtures, and configuration files, as well as the test structure and commonly used assertions. Additionally, it provides examples of GET requests for promotions and categories from a specified API.

Uploaded by

July Moe
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

2.Create Sample API Test Script

The document outlines the Cypress request methods for making HTTP calls, including various formats such as cy.request(url) and cy.request(method, url, body). It also describes the Cypress project structure, including folders for tests, fixtures, and configuration files, as well as the test structure and commonly used assertions. Additionally, it provides examples of GET requests for promotions and categories from a specified API.

Uploaded by

July Moe
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Cypress request

Request is designed to be the simplest way possible to


make http calls .Cypress make an HTTP request.
• cy.request(url)
• cy.request(url, body)
• cy.request(method, url)
• cy.request(method, url, body)
• cy.request(options)

GENERAL
cy.request(url)
• cy.request("https://
jsonplaceholder.cypress.io/comments");

GENERAL
cy.request(url, body)
• cy.request('https://
jsonplaceholder.cypress.io/posts', {
"key": "value1",
"key2": "value2"
})

GENERAL
cy.request(method, url)
cy.request("GET",
"https://jsonplaceholder.cypress.io/comments");

GENERAL
cy.request(method, url, body)
• cy.request( "POST",
'https://jsonplaceholder.cypress.io/posts',
{"one": "1 value","two": "2 value"})

GENERAL
Cypress project Structure
• Create cypress test cy.js files under e2e folder
• Json files under fixtures folder
• Test file creenshots save under screenshots folder
• Support folder use support files(command.js and e2e.js)
• Create commands in command.js file
• e2e.js file loaded automatically before running tests
• Test file videos save under videos folder
• cypress.config.js for configuration
• package.json (add dependency and needed scripts)

GENERAL
Real project Package.json
• Scripts for run shortcut, repository for git and devDependencies for
dependency used in real project

GENERAL
Test Structure
• The test interface, borrowed from Mocha,
provides describe(), context(), it() and specify().

• context() is identical to describe() and specify() is


identical to it(), so choose whatever terminology works
best for you.

GENERAL
Test hook
• describe('TestSuite Name', function() { });
• it('Test Case Name', function() { })
• Cypress provides two tags: ".only" and ".skip"to implement the
inclusion/exclusion strategy for the test runs
• describe.only('TestSuite Name', function() { });//only run testSuite
• describe.skip('TestSuite Name', function() { });//skip testSuite
• it.only('Test Case Name', function() { })//only run this test case
• it.skip('Test Case Name', function() { })//skip this test case

GENERAL
Mostly used assertions in project
Chainer Example
not expect(name).to.not.equal('Jane')
true expect(true).to.be.true
false expect(false).to.be.false
property(name, [value]) expect(obj).to.have.property('name')
lengthOf(value) expect('test').to.have.lengthOf(4)
equal expect(1).to.equal(1);
expect('foo').to.equal('foo');

GENERAL
feeTable Get Method

GENERAL
Assignment Get promotion list &
details (get-promotion.cy.js)

• https://preprodnewapi.wavemoney.io:8112/v2/mfs-
customer/categories (Get category)
• https://preprodnewapi.wavemoney.io:8112/v2/mfs-
customer/promotions/categories/categoryId(from get
category API)

GENERAL

You might also like