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

208
Views
getting error when running test for create user

Im trying to run a chai test on my website, it should create user when run, but it gives me this error when i run it:

Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/mikkelwager/Documents/GitHub/Exercise/tests/test.js)
  • here is my code, can anyone help

    var User = require("../api/models/User"); const db = require("../api/db/db.js");

      const chai = require("chai");
      const chaiHttp = require("chai-http");
      const router = require("../server");
    
      chai.use(chaiHttp);
      should = chai.should();
    
      //test af /opretBruger (krav 1)
      describe("POST /createUser", () => {
        it("It should POST a new user", (done) => {
          const user = {};
          chai
            .request(router)
            .post("/createUser")
            .set('content-type', 'application/json')
            .send({
              first_name: 'test',
              last_name: 'test',
              email: 'test@test',
              phone: '2233223',
              street: 'test',
              zip_code: '1332',
              city: 'test',
              password: 'test',
              member: '1',
            })
            .end(function (error, response, body) {
              if (error) {
                done(error);
              } else {
                done();
              }
            });
        });
      });
    
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

can you please make it an anonymous function and give it a try or if you have used the faketimers() then remove it.

about 4 years ago · Juan Pablo Isaza Report
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!