Supertest Prefix
An extension to supertest which adds a prefix to the routes
Usage
import request from 'supertest';
import supertestPrefix from 'supertest-prefix';
const prefix = supertestPrefix('/api');
await request
.get('/cars')
.use(prefix)
.expect(200);
await request
.get('http://localhost:3000/cars')
.use(prefix)
.expect(200);
Using with npm 'superagent-defaults'
https://www.npmjs.com/package/superagent-defaults
import supertest from 'supertest';
import defaults from 'superagent-defaults';
import supertestPrefix from 'supertest-prefix';
const prefix = supertestPrefix('/api');
var request = defaults();
request
.use(prefix);
await request
.get('/cars')
.expect(200);
Contributors
Would you like to contribute to this library? Don't be shy! Contact me if you are interested on it.