Skip to content

Instantly share code, notes, and snippets.

@lpinca
Created October 19, 2015 09:25
Show Gist options
  • Save lpinca/7f5cac993da4143ac69c to your computer and use it in GitHub Desktop.
Save lpinca/7f5cac993da4143ac69c to your computer and use it in GitHub Desktop.
Istanbul GH-464
'use strict';
exports.foo = function foo() {
return 'bar';
};
exports.baz = function baz() {
return 'qux';
};
{
"name": "gh-464",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"coverage": "istanbul cover _mocha",
"test": "mocha"
},
"author": "",
"license": "ISC",
"devDependencies": {
"istanbul": "^0.4.0",
"mocha": "^2.3.3"
}
}
describe('issue', function () {
'use strict';
const assert = require('assert');
const lib = require('./');
const vm = require('vm');
const context = vm.createContext({});
vm.runInContext(lib.baz.toString(), context);
it('has a `foo` function', function () {
assert.strictEqual(typeof lib.foo, 'function');
assert.strictEqual(lib.foo(), 'bar');
});
it('has a `baz` function', function () {
assert.strictEqual(typeof context.baz, 'function');
assert.strictEqual(context.baz(), 'qux');
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment