Created
October 19, 2015 09:25
-
-
Save lpinca/7f5cac993da4143ac69c to your computer and use it in GitHub Desktop.
Istanbul GH-464
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
exports.foo = function foo() { | |
return 'bar'; | |
}; | |
exports.baz = function baz() { | |
return 'qux'; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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