API Testing Using Postman Part 15: How to write API test cases in Postman using JavaScript

Published: 01 October 2021
on channel: Testing Tutorialspoint
721
16

Pre-req:
const moment = require('moment');

pm.collectionVariables.set("todayDate",moment().format("YYYY-MM-DD"));

pm.collectionVariables.set("todayDate1",(new Date()).toISOString());

pm.collectionVariables.get("todayDate1");

pm.collectionVariables.set("Name","morpheus");

pm.collectionVariables.set("Job","leader");

Tests Code:

var jsonData = pm.response.json();

pm.test("varify name", function(){
pm.expect(jsonData.name).to.eql("morpheus");
});

pm.collectionVariables.set("ID",jsonData.id);


Watch video API Testing Using Postman Part 15: How to write API test cases in Postman using JavaScript online, duration hours minute second in high quality that is uploaded to the channel Testing Tutorialspoint 01 October 2021. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 721 times and liked it 16 visitors.