Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
Jest timeout when unit testing my express controller with async/await

So, using supertest and jest, when testing my simple controller I get a timeout message. I'm not sure if I am missing something from the config for jest set-up?

app.ts

import express from 'express'
import bodyParser from 'body-parser'
import cors from 'cors'
import { UserRoute } from './components/user'

const App = () => {
  const app = express()
  app.use(bodyParser.json({ limit: "50mb" }))
  app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }))
  app.use(cors())

  app.use('/api/auth', UserRoute)

  return app
}

export default App

user.controller.ts

export const SignUp = async (req: Request, res: Response, next: NextFunction) => {
  res.json({ message: "pass!" });
}

user.route.ts

import { Router } from 'express'
import { SignUp } from './user.controller'

const router = Router()

router
  .route('/signup')
  .get(SignUp)

export default router

user.controller.spec.ts

import App from '../../../app'
import supertest from 'supertest'

const request = supertest(App);

describe('Testing user controller', () => {

  it('testing /signup', async () => {
    const res = await request.get("/signup");
    expect(res.body.message).toBe("pass!");
  })
})

My jest timeout is 10000, not sure what is missing here for my controller not to return? Potentially to do with async/await?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!