talawa-api icon indicating copy to clipboard operation
talawa-api copied to clipboard

Update the `CONTRIBUTING.md` file on the correct way to run all tests

Open palisadoes opened this issue 3 years ago • 2 comments

Describe the bug

We need to get the test coverage of our code base to 100%. Unfortunately our CONTRIBUTING.md file has incorrect information on how to run all tests correctly.

Following the procedure in the document, most tests fail with a Error: Error: connect ECONNREFUSED 127.0.0.1:4000 error because the API is not running. This means that after the command is run only three files are checked:

  • constants.js
  • getToken.js
  • getUserId.js

As you can see here after running the npm run test command without the API running.

----------------------------|---------|----------|---------|---------|-------------------
File                        | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------------------------|---------|----------|---------|---------|-------------------
All files                   |    62.5 |       50 |      50 |    62.5 |                   
 talawa-api                 |      75 |       50 |     100 |      75 |                   
  constants.js              |      75 |       50 |     100 |      75 | 4                 
 talawa-api/tests/functions |   58.33 |      100 |      50 |   58.33 |                   
  getToken.js               |   66.66 |      100 |     100 |   66.66 | 24-25             
  getUserId.js              |      50 |      100 |       0 |      50 | 6-24              
----------------------------|---------|----------|---------|---------|-------------------
Test Suites: 14 failed, 14 total
Tests:       58 failed, 58 total
Snapshots:   0 total
Time:        327.831 s
Ran all test suites.

Because only 3 files are checked, we get an erroneous code coverage percentage of 68.8% after running this command:

genhtml coverage/lcov.info -o coverage

Here is the output:

Processing file talawa-api/constants.js
Processing file talawa-api/tests/functions/getUserId.js
Processing file talawa-api/tests/functions/getToken.js
Writing directory view page.
Overall coverage rate:
  lines......: 68.8% (11 of 16 lines)
  functions..: 50.0% (1 of 2 functions)

To Reproduce

See above

Expected behavior

The documentation needs to be updated to show how to ensure that:

  • All tests run
  • The code coverage value is correctly shown

Actual behavior

See above

Screenshots

N/A

Additional details

This similar issue addresses the fact that tests don't run correctly in our GitHub actions.

  • https://github.com/PalisadoesFoundation/talawa-api/issues/423

palisadoes avatar Jan 09 '22 23:01 palisadoes

@palisadoes I would like to work on this. Can you assign this to me? This will be my first issue

Radhesh-Sarma avatar Jan 18 '22 07:01 Radhesh-Sarma

Hello @Radhesh-Sarma, I am unassigning you due to no activity.

SiddheshKukade avatar Dec 03 '22 09:12 SiddheshKukade

Hi @SiddheshKukade! I would like to pick up this issue if it's still available to be worked on.

iamansoni avatar Jan 22 '23 16:01 iamansoni

This has been fixed. Code coverage is now correct.

palisadoes avatar Jan 22 '23 17:01 palisadoes