postmanlabs / gsoc

Postman - Google Summer of Code
Apache License 2.0
33 stars 10 forks source link

NYC Code Coverage #21

Closed tirtawr closed 3 years ago

tirtawr commented 4 years ago

Hi!

So I'm trying to get started a little bit and make a tiny POC of what I'm trying to make. One thing I noticed is that for some reason nyc is not reporting the code coverage of any of the unit tests.

For example if I run the test for curl by running:

npm run test curl

The output for the unit test part looks like this:

Running unit tests using mocha on node...

  curl convert function
    Convert function
      ✓ should return snippet with carat(^) as line continuation character for multiline code generation
      ✓ should parse header with string value properly
      ✓ should return snippet without errors when request object has no body property
      ✓ should return snippet with backslash(\) character as line continuation character for multiline code generation
      ✓ should not encode queryParam unresolved variables and leave it inside double parenthesis {{xyz}}
      ✓ should encode queryParams other than unresolved variables
      ✓ should trim header keys and not trim header values
      ✓ should generate snippets for no files in form data
      getUrlStringfromUrlObject function
        ✓ should return empty string for an url object for an empty url or if no url object is passed
        ✓ should add protocol if present in the url object
        ✓ should add the auth information if present in the url object
        ✓ should not add the auth information if user isn't present but password is present in the url object
        ✓ should add host if present in the url object
        ✓ should add port if present in the url object
        ✓ should add path if present in the url object
        ✓ should add hash if present in the url object
        queryParams
          ✓ should not encode unresolved query params
          ✓ should encode query params other than unresolved variables
          ✓ should not encode unresolved query params and encode every other query param, both present together
          ✓ should discard disabled query params

  package.json
    ✓ should have com_postman_plugin object with valid properties
    ✓ should have main property with relative path to object with convert property

  22 passing (16ms)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================

Could it be a misconfiguration on my part?

Thanks

AliabbasMerchant commented 4 years ago

I am also encountering the same thing. Unknown coverage summary.
I think its a misconfiguration on our part. Because the travis build logs is properly showing all test coverage: https://travis-ci.com/github/postmanlabs/postman-code-generators/jobs/305203146#L5015

AliabbasMerchant commented 4 years ago

I think I got the issue. Its an issue with nyc and the version of node. Travis uses node version 8. I was locally using node v12.14.1.
I hence ran a docker image of node v8 and ran the tests inside it. The coverage reports are correctly shown.

Just for reference, I have opened an issue in nyc regarding the same.