Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your makefile has many issues.</p> <p>1- Why do you need the TESTS variable? Your tests are in the test/ subdirectory, so unless you have other .js files there (why would you?), then this is the default for mocha: "By default mocha(1) will use the pattern ./test/*.js, so it’s usually a good place to put your tests."</p> <p>2- Both your <code>test:</code> and <code>test-cov:</code> entries set the EXPRESS_COV environment variable to 1, meaning that you have no way to run tests without the coverage option (no way with the makefile, that is). This may be fine if you always want to do tests with coverage, but then why have 2 entries? Look at the <a href="https://github.com/visionmedia/express/blob/master/Makefile" rel="nofollow">express library Makefile</a> for a good example. If you follow this example, your <code>test:</code> entry should NOT set EXPRESS_COV.</p> <p>3- Your gen-cov entry is wrong, it should in fact be called <code>app-cov:</code> based on the name of the subdirectory where you store your instrumented files. By the way, why not choose the standard "lib-cov" (and "lib" for your non-instrumented js files)? Certainly not required, but it is a convention followed by many in the community.</p> <p>4- Why do you remove your instrumented files before running jscoverage? Not sure if it can cause problems with make, don't think so, but it's useless and should be removed.</p> <p>5- test-cov should now depend on app-cov (that's probably the heart of the problem, make never detected that the dependency was outdated, because the dependency doesn't exist!). test-cov does and should indeed set the EXPRESS_COV=1 environment variable.</p> <p>6- In test-cov, your "l" in coverage.html seems to be on a separate line, though it could be the pastebin.</p> <p>To recap (I've kept app and app-cov, though I suggest lib and lib-cov):</p> <pre><code>REPORTER = dot test: @NODE_ENV=test ./node_modules/.bin/mocha -b \ --reporter $(REPORTER) app-cov: jscoverage app app-cov test-cov: app-cov @EXPRESS_COV=1 $(MAKE) test REPORTER=html-cov &gt; docs/report/coverage.html .PHONY: test </code></pre> <p>Edit: And I just noticed that in your test code, you <code>require</code> a model explicitly in the /app/ folder. You must use the EXPRESS_COV variable as you did in the index file.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COI'm refactoring a silex application into a node.js project, I maintained the conventions. mocha would not read my tests recursively, is the reason for the tests var. The redundant EXPRESS_COV was something I was using to debug the issue before I posted. I simply followed the makefile semantics from a tutorial. The wiring doesn't seem to be the issue, nothing you've pointed out is broken by implementation, just semantics. I agree I am misunderstanding a key point in test bootstrapping for the coverage to be analyzed, if you can spot that it would be a lot more helpful.
      singulars
    2. CO#3 is not semantics, it is how make works. I'm pointing out numerous issues in your code, I cannot magically know that it was there for debug, I analyze what's posted. My edit tells you why you don't see coverage, since this is your only test, it loads explicitly from app (and not app-cov). And even then, you test if a property exists, depending on the implementation of your model, this may not cover any code. If you call a method on your model, then it will test something.
      singulars
    3. COfrom the posted makefile, running `make gen-cov` will have the intended effect. I do not understand your misconception. gen-cov is not a directory, it is a target. In that example I just did not have it set as phony. I have a very anaemic model, by design, and without complex domain operations. This is just a lightweight data store so testing properties will be probably be the girth of my unit tests. After all, instantiating a model and testing for the expected properties makes sense if the model is schema'd by mongoose.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload