mkdir postman_collection
cd postman_collection
touch ecommerceApp.postman_testing.json
Then upload the file from your project folder/postman_collection folder.
//Get the current response from the postman global object which will be of type json.
const response = pm.response.json();
pm.test('Note', () => {
//Test Callback
});
//Get the current response from the postman global object which will be of type json.
const response = pm.response.json();
//Do the pm.test to perform a test with a note, which can be anything, and a callback performing the test.
pm.test('check the status code is 200', () => {
//Use chai language chains to improve the readability of the test on the pm object.
pm.response.to.have.status(200);
})
//Now we are gonna make it purposely fail.
pm.test('check if the status code 201', () => {
//Use chai language chains to improve the readability of the test on the response VARIABLE.
response.to.have.status(201)
})
Completed 1st Test.
//Get the current response from the postman global object which will be of type json.
const response = pm.response.json();
//Do the pm.test to perform a test with a note, which can be anything, and a callback performing the test.
pm.test('check the status code is 200', () => {
//Use chai language chains to improve the readability of the test on the pm object.
pm.response.to.have.status(200);
})
//Do the pm.test to perform a test with a note, which can be anything, and a callback performing the test.
pm.test('check if response is an array', () => {
//Use chai language chains to improve the readability of the test on the pm object.
//Test if the resposne is an array
pm.expect(response).to.be.an('array');
})
//Now we are gonna make it purposely fail.
pm.test('check if response is a object', () => {
//Use chai language chains to improve the readability of the test on the response VARIABLE.
//Test if the response is an object
pm.expect(response).to.be.an('object');
})
Completed 2nd Test
//Get the current response from the postman global object which will be of type json.
const response = pm.response.json();
//Do the pm.test to perform a test with a note, which can be anything, and a callback performing the test.
pm.test('check the status code is 200', () => {
//Use chai language chains to improve the readability of the test on the pm object.
pm.response.to.have.status(200);
})
//Do the pm.test to perform a test with a note, which can be anything, and a callback performing the test.
pm.test('check if response is an object', () => {
//Use chai language chains to improve the readability of the test on the pm object.
//Test if the resposne is an array
pm.expect(response).to.be.an('object');
})
//Now we are gonna make it purposely fail.
pm.test('check if response is a array', () => {
//Use chai language chains to improve the readability of the test on the response VARIABLE.
//Test if the response is an object
pm.expect(response).to.be.an('array');
})

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store