Five, postman-sandbox

First, run some JavaScript code in place of the postman

  • Public Library (javascript)
  • Environment variables and global variables
  • Dynamic variables
  • Operating cookie
  • Access and view the request and response
  • Read data files

Two, api documentation

https://www.getpostman.com/docs/postman/scripts/postman_sandbox_api_reference

pm.test('environment to be production',function(){
    pm.expect(pm.environment.get( 'env' )).to.equal( 'production' );
});
pm.test("response should be okay to process",function(){
    pm.response.to.not.be.error;
    pm.response.to.have.jsonBody('');
    pm.response.to.not.have.jsonBody( 'error' );
});

Examples of operation

tests [ "status code must be 200 is"] = 200 is responseCode.code ===; 

var the JSON.parse RES = (the responseBody); 

the console.log (res.length); 

tests [ "10 must return data"] = res === 10 .length; 

pm.test ( 'returns the correct code', function () { 
    pm.expect (pm.response) .to.have.status (200 is); 
    pm.expect (pm.response). to.be.success; 
});

 

Guess you like

Origin www.cnblogs.com/xinxin1994/p/11258711.html