Giter VIP home page Giter VIP logo

Comments (7)

gotwarlost avatar gotwarlost commented on June 19, 2024

Looks like dojo may be doing something that doesn't play well with what istanbul does.

In order for me to debug this, would it be possible for you to set up a small project on github with package.json, code, tests etc. and give me a link? That way I can start looking at the problem rather than trying to figure out how to set up all this.

from istanbul.

adabadyitzaboy avatar adabadyitzaboy commented on June 19, 2024

you can download the zip and unzip it if that's easier for you.

Once you unzip it, I was running the command
istanbul cover istanbul-test.js (for scenario 1)
istanbul cover istanbul-test2.js (for scenario 2)

here is the link: https://github.com/adabadyitzaboy/istanbul-AND-dojo

from istanbul.

gotwarlost avatar gotwarlost commented on June 19, 2024

OK, looked at your examples, thanks for providing something simple for me to work with.

Two issues:

  1. dojo uses vm.runInThisContext to load the user code so you need to pass --hook-run-in-context to the istanbul cover command
  2. There is an issue with the way filenames are matched for the purposes of hooking - the current code assumes that absolute path names will be passed to it whereas in the dojo case it is getting a relative path name (i.e. ./test.js as opposed to /path/to/file/test.js)

For fixing (2) temporarily to make progress (I will provide a proper fix later):

Change this line: https://github.com/gotwarlost/istanbul/blob/master/lib/hook.js#L43
to read as:

var shouldHook = matcher(require('path').resolve(filename))

That should get you to a state where the coverage report shows test.js covered at 100% when using the command:

$ ./istanbul cover --hook-run-in-context istanbul-test.js 

Let me know if that works and any other issues you find after this. Thanks!

from istanbul.

adabadyitzaboy avatar adabadyitzaboy commented on June 19, 2024

Awesome!

This helped so much! Now I just need to figure out if I can fake a browser so that i can have the global window.

from istanbul.

gotwarlost avatar gotwarlost commented on June 19, 2024

JSDOM maybe? https://github.com/tmpvar/jsdom

from istanbul.

adabadyitzaboy avatar adabadyitzaboy commented on June 19, 2024

Thank you for your help.

JSDOM definately did the job for me.
I was able to work through some other issues and now everything is working fine. Thank you so much. I was beating my head against the wall for the 1st issue. Now we have code coverage :). Now to just get it to an acceptable range before showing the head bosses ...hehehe

from istanbul.

gotwarlost avatar gotwarlost commented on June 19, 2024

path fix available in v0.1.35

from istanbul.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.