Skip to the content.

TEST SCRIPTS

GET ALL PLAYERS

GET /players
pm.test('Status code is 200', function () {
    pm.response.to.have.status(200); 
});
pm.test('Status code is 400', function () {
    pm.response.to.have.status(400); 
});

GET SPECIFIC PLAYER

GET /player?id=
var player_list=pm.response.json().data.players;
pm.environment.set('player_id', player_list[Math.floor(Math.random() * player_list.length)].id);
pm.test('Status code is 400', function () {
    pm.response.to.have.status(400); 
});
var player_list=pm.response.json().data.players;
pm.environment.set('player_id', player_list[Math.floor(Math.random() * player_list.length)].id);
if(!pm.variables.get('player_id')) pm.variables.set('player_id', -1);
GET https://6d338fbc-93bd-456e-85a0-818bd4cd3177.mock.pstmn.io/player?id=-1

GET STATS

pm.test('Status code is 200', function () {
    pm.response.to.have.status(200); 
});
pm.test('Stats include all fields', function () {
    var jsonData = pm.response.json().data;
    pm.expect(jsonData).to.have.all.keys('won', 'lost', 'drew');
});
pm.test('Status code is 200', function () {
    pm.response.to.have.status(200); 
});
pm.test('Stats include all fields', function () {
    var jsonData = pm.response.json().data;
    pm.expect(jsonData).to.have.all.keys('won', 'lost', 'drew');
});
GET ALL PLAYERS
GET SPECIFIC PLAYER
GET STATS
if(pm.response.json().data.played<750) postman.setNextRequest('Get all players');