Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeerror on callback #790

Open
vividsystem opened this issue Sep 28, 2022 · 1 comment
Open

typeerror on callback #790

vividsystem opened this issue Sep 28, 2022 · 1 comment

Comments

@vividsystem
Copy link

So I am having a very random error on the response callbacks my tests look something like this:

  it('POST / -> successful', () => {
    let username = (Date.now()).toString(32);
    let email = `${(Date.now()).toString(32)}@test.dev`
    let password = `${(Date.now()).toString(32)}@123`
    return request(userRouter)
      .post('/')
      .send({ name: username, email: email, password: password })
      .expect(201)
      .expect('Content-Type', /json/)
      .then((response) => { // error happens after breakpoint here
        expect(response.body).toEqual(
          expect.objectContaining({
            id: expect.any(Number),
            createdAt: expect.stringMatching(timeRegex),
            name: expect.stringMatching(username),
            email: expect.stringMatching(email)
          })
        );
        testUsers.push(response.body as User)
      }, (response) => {
        console.log(response)
      });
  });

After some debugging using Visual Studio Code's Debug features. I figured the error happened after the breakpoint but I couldn't find out more since

@vividsystem vividsystem changed the title error on callback weird very random error on callback Sep 28, 2022
@vividsystem
Copy link
Author

I am getting the following error:
TypeError: Cannot read property 'apply' of undefined

@vividsystem vividsystem changed the title weird very random error on callback typeerror on callback Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant