Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3643

Is there any way to set defaults in supertest?

$
0
0

I'm using the supertest module to test my Rest API. my API sends JSON all the time. so I'm doing .expect('Content-Type', /json/) for all and each test! I'm repeating again and again!

this is some of my code

it('should list ALL permissions on /permissions GET', (done)=> {    request(app)        .get( permissionsURL )        .expect(200)        .expect('Content-Type', /json/)        .end((err, res)=> {            var permissions = res.body;            permissions.should.be.an.instanceOf(Array);            var permission = permissions[0];            permission.should.be.json;            permission.should.have.properties(['name', '_id']);            permission.name.should.be.a.String();            // permission.should.not.have.property('__v');            done(err);        });});it('should list a SINGLE permission on /permissions/<id> GET', (done)=> {    request(app)        .get( permissionsURL +savedPermissionId )        .expect(200)        .expect('Content-Type', /json/)        .end((err, res)=> {            var permission = res.body;            permission.should.be.json;            permission.should.have.properties(['name', '_id']);            permission.name.should.be.a.String();            // permission.should.not.have.property('__v')            done(err);        });});

Is there any other way? somethink like the superagent-defaults module but for supertest not superagent? or is it possible to use superagent-defaults with supertest?

thank you for any help you are able to provide. :)


Viewing all articles
Browse latest Browse all 3643

Trending Articles