0

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();
              }
            });
        });
      });
    
Wager2000
  • 31
  • 4

1 Answers1

0

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

Manik Kumar
  • 764
  • 7
  • 17