I'm trying to write tests for my app to test the api. I'm using swagger for specs, but whenever I try to make a request to an endpoint that works fine in my browser, I'm getting a 404.
Additionally, as you might see in the code block, I don't really know what to pass in as "app". This snippet came from the Hippie-swagger docs http://ift.tt/1R9m08k
Here is the test I'm writing:
var hippie = require('hippie-swagger');
var swagger = require('../../swagger.json');
var SwaggerParser = require('swagger-parser')
//var app = require('../../app.js')
var parser = new SwaggerParser()
var path = require('path')
var app = require('express')
var dereferencedSwagger
var swagger = require('../../swagger.json')
describe('Example of', function () {
before(function (done) {
// if using mocha, dereferencing can be performed prior during initialization via the delay flag:
// http://ift.tt/1MOusSj
parser.dereference(path.join(__dirname, '../../swagger.json'), function (err, api) {
console.log("ERR", err);
if (err) return done(err)
dereferencedSwagger = api
done()
})
})
describe('correct usage', function () {
it('works when the request matches the swagger file', function (done) {
hippie(app, dereferencedSwagger)
.get('/admin')
// .pathParams({
// data: 1
// })
//.send({"communityId":"tech","code":"1"})
.expectStatus(200)
//
.end(done)
})
})
})
Aucun commentaire:
Enregistrer un commentaire