How to write test with supertest #96
-
I used supertest to write api test with express project Express Projectapp.tsimport express from 'express'
const app = express()
app.use(express.json({ limit: '50mb' }))
app.use(express.urlencoded({ extended: false }))
export default app Hyper Expressapp.tsimport HyperExpress from 'hyper-express'
const app = new HyperExpress.Server({ max_body_length: 50 * 1000000 }) // 50mb
export default app Testrouter.test.tsimport request from 'supertest'
import app from '../../../app'
describe('GET /', () => {
it('Should response status code 200', async () => {
const res = await request(app).get('/')
expect(res.status).toEqual(200)
})
})
afterAll((done) => {
done()
}) This test is work on
How to fix this? or How Hyper-Express write api test? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
HyperExpress is not 100% drop-in compatible with ExpressJS and it seems that some of the logic is trying to call a method called You can add this method yourself onto your |
Beta Was this translation helpful? Give feedback.
HyperExpress is not 100% drop-in compatible with ExpressJS and it seems that some of the logic is trying to call a method called
Server.address()
which currently is not implemented with HyperExpress.You can add this method yourself onto your
app
if you understand the behavior of this method or wait for future updates which may add compatibility for this method.