constants.js 500 B

123456789101112131415161718
  1. var browserify = require('../');
  2. var test = require('tap').test;
  3. var vm = require('vm');
  4. var through = require('through2');
  5. test('constants', function (t) {
  6. t.plan(2);
  7. var stream = through();
  8. stream.push('console.log(require("constants").ENOENT)');
  9. stream.push(null);
  10. var b = browserify(stream);
  11. b.bundle(function (err, src) {
  12. t.ifError(err);
  13. vm.runInNewContext(src, { console: { log: log } });
  14. function log (msg) { t.equal(msg, 2) }
  15. });
  16. });