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

[fix] Tests timeout no matter what if expect fails. #837

Open
Jason-Terry opened this issue May 3, 2024 · 1 comment
Open

[fix] Tests timeout no matter what if expect fails. #837

Jason-Terry opened this issue May 3, 2024 · 1 comment
Labels

Comments

@Jason-Terry
Copy link

Describe the bug

Node.js version: v20.10.0
OS version: MAC 14.2.1 (23C71)

The following test returns 200, however when trying to force the test to fail by expecting status to be 201 as below, the test always times out, and doesn't fail immediately.

How can I prevent this.

it('should return account ids', done => {
    request(app).get('/api/v1/account/info/ids').set(headers).end((err, res) => {
      expect(res.status).toBe(201);
      expect(res.body.message).toEqual("Last 1000 Ids added...");
      done();
    });
  });

another example, this time similar to the async await example from the readme.

  it('should return account info by id', async () => {
    let res = await request(app).get(`/api/v1/account/info/ids/${expected.id}`).set(headers);
      expect(res.body.id).toEqual(999); // <-- THIS IS A FAILURE, TIMES OUT...
      expect(res.body.wc_customer_id).toEqual(expected.wc_customer_id);
      expect(res.body.chrono_patient_id).toEqual(expected.chrono_patient_id);
      expect(res.body.klaviyo_profile_id).toEqual(expected.klaviyo_profile_id);
      expect(res.body.suggestic_db_id).toEqual(expected.suggestic_db_id);
      expect(res.body.email).toEqual(expected.email); 
  });

Actual behavior

Test times out rather than returning on failure, or continuing to run.

Expected behavior

Test would check all assertions OR exit properly on assertion failure.

Code to reproduce

Any test similar to the example above.

Checklist

  • [ x] I have searched through GitHub issues for similar issues.
  • [ x] I have completely read through the README and documentation.
  • [ x] I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
@Jason-Terry Jason-Terry added the bug label May 3, 2024
@Jason-Terry Jason-Terry changed the title [fix] DESCRIPTIVE TITLE [fix] Tests timeout no matter what if expect fails. May 3, 2024
@ryaneclpse
Copy link

@Jason-Terry Have you tried this:

it('should return account info by id', async function() {
    this.timeout(60000);
    let res = await request(app).get(`/api/v1/account/info/ids/${expected.id}`).set(headers);
      expect(res.body.id).toEqual(999); // <-- THIS IS A FAILURE, TIMES OUT...
      expect(res.body.wc_customer_id).toEqual(expected.wc_customer_id);
      expect(res.body.chrono_patient_id).toEqual(expected.chrono_patient_id);
      expect(res.body.klaviyo_profile_id).toEqual(expected.klaviyo_profile_id);
      expect(res.body.suggestic_db_id).toEqual(expected.suggestic_db_id);
      expect(res.body.email).toEqual(expected.email); 
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants