starworld-mock-api
Version:
A server that responds with mock data.
22 lines (19 loc) • 613 B
JavaScript
const request = require('supertest')
const {baseUrl, matchesField, clearEndpoints} = require('../integration/utils')
const {registerEndpoint} = require('../../src')
afterEach(clearEndpoints)
test('Can register a GET endpoint that returns JSON', () => {
return registerEndpoint(baseUrl, {
endpoint: '/test',
body: {
a: 'AAA',
b: 'BBB',
},
})
.then(() => {
return request(baseUrl).get('/test')
.expect(200)
.expect(matchesField('a', 'AAA'))
.expect(matchesField('b', 'BBB'))
})
})