How to use the proxyquire.noPreserveCache 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 AugurProject / augur.js / test / unit / create-market / get-market-creation-cost.js View on Github external
/* eslint-env mocha */

"use strict";

var assert = require("chai").assert;
var speedomatic = require("speedomatic");
var proxyquire = require("proxyquire").noPreserveCache();

describe("create-market/get-market-creation-cost", function () {
  var test = function (t) {
    it(t.description, function (done) {
      var getMarketCreationCost = proxyquire("../../../src/create-market/get-market-creation-cost", {
        "../api": t.stub.api,
      });
      getMarketCreationCost(t.params, function (err, marketCreationCost) {
        t.assertions(err, marketCreationCost);
        done();
      });
    });
  };
  test({
    description: "happy path",
    params: {
github AugurProject / augur.js / test / unit / trading / order-book / get-order-book-chunked.js View on Github external
/* eslint-env mocha */

"use strict";

var assert = require("chai").assert;
var proxyquire = require("proxyquire").noPreserveCache();

var callcount = 0;

describe("trading/order-book/get-order-book-chunked", function () {
  var test = function (t) {
    it(t.description, function () {
      callcount = 0;
      var getOrderBookChunked = proxyquire("../../../../src/trading/order-book/get-order-book-chunked", {
        "./get-order-book": t.stub.getOrderBook,
        "../../api": function () {
          return {
            Orders: {
              getWorseOrderId: t.stub.api.Orders.getWorseOrderId
            }
          };
        }
github mozilla / fxa-auth-server / test / local / user_agent.js View on Github external
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict';

const { assert } = require('chai');
const proxyquire = require('proxyquire').noPreserveCache();
const sinon = require('sinon');

describe('userAgent, mocked dependency', () => {
  let uaParser, userAgent, parserResult;

  beforeEach(() => {
    uaParser = {
      parse: sinon.spy(() => parserResult)
    };

    userAgent = proxyquire('../../lib/userAgent', {
      'node-uap': uaParser
    });
  });

  it(
github dowjones / fiveby / test / spec / logManager.js View on Github external
/* global describe, it, before, assert, promise */
var proxyquire = require('proxyquire').noPreserveCache();
var webdriver = require('selenium-webdriver');

//global.run = function () {};

var fsStub = {
  existsSync: function () {
    return false;
  },
  mkdirSync: function (path, perm, cb) {
    cb('muhaha');
  },
  writeFile: function (name, message, cb) {
    cb();
  }
};
github shime / play-sound / tests.js View on Github external
var expect     = require('expect.js')
  , sinon      = require('sinon')
  , mock       = require('mock-fs')
  , proxyquire = require('proxyquire').noPreserveCache()

describe('mplayer has the maximum priority', function(){
  var spy, cli

  beforeEach(function(){
    spy = sinon.stub()
    cli = proxyquire('./', { child_process: { spawn: spy }})()

    mock({
      './beep.mp3': '',
      'mplayer': mock.file({
        mode: 0755
      })
    })
  })
github avajs / ava / test / beautify-stack.js View on Github external
'use strict';
require('../lib/chalk').set();
require('../lib/worker/options').set({});

const proxyquire = require('proxyquire').noPreserveCache();
const {test} = require('tap');
const Runner = require('../lib/runner');

const beautifyStack = proxyquire('../lib/beautify-stack', {
	debug() {
		return {
			enabled: false
		};
	}
});

function fooFunc() {
	barFunc();
}

function barFunc() {
github zalando / tailor / tests / transform.js View on Github external
'use strict';

const assert = require('assert');
const sinon = require('sinon');
const proxyquire = require('proxyquire').noPreserveCache();

describe('Transform', () => {
    let Transform;
    let transformInstance;

    class MockSerializer {
        constructor(node, options) {
            this.node = node;
            this.options = options;
        }
        serialize() {}
    }

    let mockSerializer = sinon.spy(function() {
        return sinon.createStubInstance(MockSerializer);
    });
github hasankhan / sql-cli / test / commands-spec.js View on Github external
var proxyquire =  require('proxyquire').noPreserveCache(),
    Q = require('q'),
    _ = require('underscore'),
    Queries = require('../lib/commands/queries'),
    Utils = require('../lib/commands/utils'),
    Invoker = require('../lib/commands').Invoker,
    EventEmitter = require('events');

describe('Invoker', () => {
    var readline, exit, invoker, db, messages, writer, request;

    function mockCommands(invoker, mocks, db, names) {
        names.forEach(name => {
            var CommandType = proxyquire('../lib/commands/' + name, mocks);
            var command = new CommandType(db);
            invoker.commands = _.map(invoker.commands, cmd => {
                return (cmd.constructor.name == command.constructor.name) ? command : cmd;
github VadimDez / watchstocks / server / api / stock / index.spec.js View on Github external
'use strict';

var proxyquire = require('proxyquire').noPreserveCache();

var stockCtrlStub = {
  index: 'stockCtrl.index',
  show: 'stockCtrl.show',
  create: 'stockCtrl.create',
  update: 'stockCtrl.update',
  destroy: 'stockCtrl.destroy'
};

var routerStub = {
  get: sinon.spy(),
  put: sinon.spy(),
  patch: sinon.spy(),
  post: sinon.spy(),
  delete: sinon.spy()
};
github gi-no / paizaqa / server / api / user / index.spec.js View on Github external
'use strict';

var proxyquire = require('proxyquire').noPreserveCache();

var userCtrlStub = {
  index: 'userCtrl.index',
  destroy: 'userCtrl.destroy',
  me: 'userCtrl.me',
  changePassword: 'userCtrl.changePassword',
  show: 'userCtrl.show',
  create: 'userCtrl.create'
};

var authServiceStub = {
  isAuthenticated() {
    return 'authService.isAuthenticated';
  },
  hasRole(role) {
    return 'authService.hasRole.' + role;

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