Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Using Mocks for Unit Tests with external Dependencies #107

@paavininanda

Description

@paavininanda

Description

As a programmer,
I need the unit tests to work properly,
so that I can have the app function without any glitches.
Currently one of the test related to authentication is failing -

Executing (default): SELECT id, fname, lname, email, password, verificationStatus, resetPasswordToken, resetPasswordExpires, provider, google_id, google_token FROM user_accounts AS user_account WHERE user_account.email = '[email protected]' LIMIT 1;
POST /auth/login 200 6.072 ms - 61
1) "before all" hook: Login
Executing (default): DELETE FROM user_accounts WHERE email = '[email protected]'
3 passing (275ms)
1 failing

  1. Testing APIs Creating User Authentication "before all" hook: Login:
    Uncaught TypeError: Cannot read property 'email' of undefined
    at Test. (test/test.js:94:34)
    at Test.assert (node_modules/supertest/lib/test.js:179:6)
    at assert (node_modules/supertest/lib/test.js:131:12)
    at node_modules/supertest/lib/test.js:128:5
    at Test.Request.callback (node_modules/superagent/lib/node/index.js:706:12)
    at parser (node_modules/superagent/lib/node/index.js:906:18)
    at IncomingMessage.res.on.e (node_modules/superagent/lib/node/parsers/json.js:19:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

It is happening because we are calling a email API in the unit tests. We need to find another way to test this.

Acceptance Criteria

Update [Required]

  • Correct the unit test

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1-2 hours

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions