I have modified example spec (refer http://editor.swagger.io/#/ example- heroku-pets) and i am trying to test this spec using swagger-test. But i am stuck at one point,
AssertionError: expected { Object (description, request, ...) } to deeply equal { Object (description, request, ...) }
What i think the reason is, i am not correctly mentioning the uri for get/ in tests.js file. Actually the uri should be- http://petstore-api.herokuapp.com/pet/?limit=11 and what my code is taking is http://petstore-api.herokuapp.com/pet/ .
My question is,How to pass input parameters(i.e. ?limit=11) in the uri in tests.js? And if i am wrong, then how to resolve this issue ?
Below is the code for my swagger.json file:
And below is the code for my tests.js file:
/* global describe, it, before, beforeEach, after, afterEach */
var fs = require('fs');var swaggerTest = require('../lib/swagger-test');var assert = require('chai').assert;
describe('test generation with inference', function () {
var testDir = __dirname; var buffer = fs.readFileSync(testDir + '/swagger.json'); var spec = JSON.parse(buffer);
var xamples = swaggerTest.parse(spec, { inferXamples: true });
it('should contain three test cases', function () { assert.equal(xamples.length, 3); }); var str= xamples[0].toString(); //console.log("str: "+str); //console.log("xamples: "+xamples);
it('should first test GET /', function () { assert.deepEqual(xamples[0], { "description": "get /", "request": { "method": "get", "uri": "petstore-api.herokuapp.com/pet/" }, "response": { "status": 200, "headers": { "content-type": "application/json" } } }); });
it ('should next test GET /560eea43a62de703006d2b57', function () { assert.deepEqual(xamples[1], { "description": "get /{petId}: returns 200 for 560eea43a62de703006d2b57", "request": { "params": { "petId": "560eea43a62de703006d2b57" }, "method": "get", }, "response": { "status": 200, "headers": { "content-type": "application/json" } } }); });
it ('should next test GET /560eea59a62de703006d2b58', function () { assert.deepEqual(xamples[2], { "description": "get /{petId}", "request": { "params": { "petId": "560eea59a62de703006d2b58" }, "method": "get", }, "response": { "status": 200, "headers": { "content-type": "application/json" } } }); });});And here is what my console is saying:
How to resolve this error? And how to pass input parameters like this one "?limit=11".