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

Does not play well with sandboxed-module #22

Open
domenic opened this issue May 10, 2012 · 3 comments
Open

Does not play well with sandboxed-module #22

domenic opened this issue May 10, 2012 · 3 comments

Comments

@domenic
Copy link
Contributor

domenic commented May 10, 2012

sandboxed-module is very useful for testing, but when my tests include a module via sandboxedModule.require, that module never gets code-covered.

If I manually include that module via require as well, then the module shows up as if no code inside it was ever run.

I can work to produce a minimal test case here if that would be helpful.

@itay
Copy link
Owner

itay commented May 10, 2012

@domenic a minimal test case would be useful. The problem is that Cover works by hooking into require, and sandboxed-module works by kind of replacing require. However, I can see if we can make them work together.

@domenic
Copy link
Contributor Author

domenic commented May 10, 2012

Here ya go. Should have just included it in the bug report.

// sut.js
var stubMe = require("stubMe");

module.exports = function () {
    if (true) {
        return 5;
    }
    return 6;
};

// test.js
var sandboxedModule = require("sandboxed-module");
var sut = sandboxedModule.require("./sut", {
    requires: { stubMe: { } }
});

// If i leave this as commented out, `sut` never even shows up in the coverage report.
// If I uncomment this, everything in `sut` shows up as uncovered.
//require("./sut");

sut();

I can definitely see where the two would interact poorly, but making them work together would be a big payoff, even if there's explicit integration (e.g. require("node-cover").useSandboxedModule(require("sandboxed-module"))).

@itay
Copy link
Owner

itay commented May 10, 2012

@domenic thank you! I'll definitely take a look. If needed, I'll talk to @felixge about it :)

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