caolan / nodeunit

Easy unit testing in node.js and the browser, based on the assert module.
MIT License
1.9k stars 370 forks source link

lcov reporter is not working #258

Open henvic opened 10 years ago

henvic commented 10 years ago

I'm trying to use the lvoc reporter on my project, but there's just no output from nodeunit.

If I invoke nodeunit test only:

henvic at henvic-mp in ~/projects/liferay/grunt-cli-config (master●●)
$ nodeunit test

config_options_test
✔ config_options - normalize
✔ config_options - parse
✔ config_options - any
✔ config_options - boolean
✔ config_options - negative

OK: 5 assertions (140ms)

If I try to invoke with the lcov reporter:

henvic at henvic-mp in ~/projects/liferay/grunt-cli-config (master●●)
$ nodeunit test --reporter lcov

If I try to invoke with the html reporter:

henvic at henvic-mp in ~/projects/liferay/grunt-cli-config (master●●)
$ nodeunit test --reporter=html
<html>
<head>
<title></title>
<style type="text/css">
body { font: 12px Helvetica Neue }
h2 { margin:0 ; padding:0 }
pre { font: 11px Andale Mono; margin-left: 1em; padding-left: 1em; margin-top:0; font-size:smaller;}
.assertion_message { margin-left: 1em; }
  ol {  list-style: none;   margin-left: 1em;   padding-left: 1em;  text-indent: -1em;}
  ol li.pass:before { content: "\2714 \0020"; }
  ol li.fail:before { content: "\2716 \0020"; }
</style>
</head>
<body>
<h2>config_options_test</h2>
<ol>
<li class="pass">config_options - normalize</li>
<li class="pass">config_options - parse</li>
<li class="pass">config_options - any</li>
<li class="pass">config_options - boolean</li>
<li class="pass">config_options - negative</li>
</ol>
<h3>OK: 5 assertions (151ms)</h3>
</body>
</html>

nodeunit version 0.8.6, node.js version 0.10.26. Repo https://github.com/henvic/grunt-cli-config

henvic commented 10 years ago

@alanshaw, maybe you want to see this.

alanshaw commented 10 years ago

Did you instrument your code? https://github.com/alanshaw/nodeunit-lcov-coveralls-example

henvic commented 10 years ago

Hi Alan, before I was loading the non-lcov 'version' of the code.

But now I'm loading the right one, but I don't get the right results as you can see in https://coveralls.io/files/168543783#L40

henvic at henvic-mp in ~/projects/liferay/grunt-cli-config (master●) $ node_modules/jscoverage/bin/jscoverage tasks && GRUNT_CLI_CONFIG_CODE_COVERAGE=1 nodeunit --reporter=lcov test coooov SF:tasks/config_options.js DA:11,1 DA:13,0 DA:20,0 DA:27,0 DA:29,0 DA:30,0 DA:33,0 DA:40,0 DA:48,0 DA:49,0 DA:52,0 DA:53,0 DA:56,0 DA:58,0 DA:62,0 DA:63,0 DA:65,0 end_of_record

Any idea why?

ecokeley commented 10 years ago

I have a problem with the lcov reporter and mocking my objects through the sandbox utility. I replace 'require' to allow mocking what is being required in a module which then screws up the code coverage numbers.