Trying to use this in a rather simple Jest test, and it produces very strange results:
const agent = require('supertest-koa-agent')
const Koa = require('koa')
it.only('Creates a Koa response', async done => {
const responseText = 'TESTING!'
const app = new Koa()
app.use(async (ctx, next) => {
await next()
ctx.body = responseText
})
const testAgent = agent(app)
const response = await testAgent.get('/').end(done)
expect(response.text).toBe(responseText)
})
const agent = require('supertest-koa-agent')
const Koa = require('koa')
it.only('Creates a Koa response', async done => {
const responseText = 'TESTING!'
const app = new Koa()
app.use(async (ctx, next) => {
await next()
ctx.body = { responseText }
})
const testAgent = agent(app)
const response = await testAgent.get('/').end(done)
expect(response.text).toBe(responseText)
})
SyntaxError: Unexpected token { in JSON at position 27
at JSON.parse (<anonymous>)
at IncomingMessage.<anonymous> (node_modules/supertest-koa-agent/node_modules/superagent/lib/node/parsers/json.js:11:35)