How to use the proxyquire.resolve function in proxyquire

To help you get started, we’ve selected a few proxyquire examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thlorenz / dog / test / publish.js View on Github external
fs = {
      writeFile : function(file, content, encoding, cb) {
        written[file] = JSON.parse(content);
        cb();
      }
    };

    // Supress all logging during tests
    log = { 
        info    :  function () {}
      , verbose :  function () {}
      , silly   :  function () {}
      , error   :  function () {}
    };

    publish = proxyquire.resolve('../lib/publish', __dirname, { 
        fs      :  fs
      , './utl' :  utl
      , npmlog  :  log 
    });
  })
github thlorenz / dog / test / publisher-integration.js View on Github external
/*jshint asi:true, esnext:true */

var proxyquire = require('proxyquire')
  , should = require('should')
  , sut = proxyquire.resolve('../lib/publisher', __dirname, { npmlog: require('./fakes/npmlog') })
  , path = require('path')
  , fs = require('fs')
  , utl = require('../lib/utl')

  , blogdir =  path.join(__dirname, 'fixtures', 'testblog')
  , blogjsonFile = path.join(blogdir, 'blog.json')

  , postunodir = path.join(blogdir, 'postuno')
  , postunojsonFile = path.join(postunodir, 'post.json') 

  , postdosdir = path.join(blogdir, 'postdos')
  , postdosjsonFile = path.join(postdosdir, 'post.json') 

  , cleanups = [ blogjsonFile, postunojsonFile, postdosjsonFile ]
  , opts

proxyquire

Proxies nodejs require in order to allow overriding dependencies during testing.

MIT
Latest version published 5 years ago

Package Health Score

74 / 100
Full package analysis