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

Default setup reports no coverage #2

Closed
mantoni opened this issue Nov 24, 2014 · 6 comments
Closed

Default setup reports no coverage #2

mantoni opened this issue Nov 24, 2014 · 6 comments

Comments

@mantoni
Copy link
Collaborator

mantoni commented Nov 24, 2014

I'm using a simple default setup to check code coverage with these results:

$ node_modules/.bin/mochify --plugin [ mochify-istanbul --report text ]
# phantomjs:

  ............

  12 passing (12ms)

---------------------|-----------|-----------|-----------|-----------|
File                 |   % Stmts |% Branches |   % Funcs |   % Lines |
---------------------|-----------|-----------|-----------|-----------|
   lib/              |     16.67 |         0 |         0 |     16.67 |
      sorter.js      |     16.67 |         0 |         0 |     16.67 |
   test/             |      3.23 |       100 |         0 |      3.23 |
      create-test.js |      3.23 |       100 |         0 |      3.23 |
---------------------|-----------|-----------|-----------|-----------|
All files            |      9.09 |         0 |         0 |      9.09 |
---------------------|-----------|-----------|-----------|-----------|

Although this project has 99.76% coverage reported by coverify:

$ node_modules/.bin/mochify --cover
# phantomjs:

  ............                                                                     

  12 passing (34ms)


# .../lib/sorter.js: line 12, column -68-41

      throw new TypeError("Sorter cannot resolve '" + keys.slice(0, i).join(".")
        + "'' from " + JSON.stringify(obj));
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# coverage: 427/428 (99.76 %)

Error: Exit 1
@ferlores
Copy link
Owner

I'm not sure if I understand the issue. Are you pointing that with istanbul you get only 16.67% of coverage on the file while coverify reports 99,76%?

If so, I would suggest you to first exclude the test file and all the modules that you are not testing (--exclude '**/+(test|node_modules)/**/*'). I will improve the exclude parameter so you can pass an array of patterns instead.

About making this the default option I'm not that convinced. In my use case I have a node_module folder checked-in in my project where I define my modules, in order to avoid require('../../../../../'). Maybe what I can do is an opt-in default configuration.

What do you think?

EDIT: I corrected the glob patter for excluding the tests and node_modules

@mantoni
Copy link
Collaborator Author

mantoni commented Nov 24, 2014

I understand the statistics like it's giving me the coverage from parsing the file, but not from running the tests. The coverage stats from coverify suggest that the actual coverage is close to 100%. This looks like a bug to me.

Regarding defaults: It lists exactly the files I want it to check. So there is nothing to exclude for me.

@ferlores
Copy link
Owner

I found the bug, great catch. The __coverage__ variable was printed out before waiting for the tests to finish 6cfd3e8

I just published v2.1.0, it also allows you to define multiple --exclude options. Please let me know if it works for you

@mantoni
Copy link
Collaborator Author

mantoni commented Nov 25, 2014

Now it works as expected. Thanks 👍

@mantoni mantoni closed this as completed Nov 25, 2014
@ferlores
Copy link
Owner

Cool. Do you mind linking this repo from the mochify README file?
Thanks!
On Nov 25, 2014 8:48 AM, "Maximilian Antoni" notifications@github.com
wrote:

Closed #2 #2.


Reply to this email directly or view it on GitHub
#2 (comment).

@mantoni
Copy link
Collaborator Author

mantoni commented Nov 25, 2014

Make it a pull request ;-)

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

2 participants