How to use the proxyquire.noCallThru 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 pelias / api / test / unit / query / address_search_using_ids.js View on Github external
const generateQuery = require('../../../query/address_search_using_ids');
const _ = require('lodash');
const proxyquire = require('proxyquire').noCallThru();
const mock_logger = require('pelias-mock-logger');
const MockQuery = require('./MockQuery');

module.exports.tests = {};

module.exports.tests.interface = (test, common) => {
  test('valid interface', (t) => {
    t.ok(_.isFunction(generateQuery));
    t.end();
  });
};

// helper for canned views
const views = {
  focus_only_function: () => 'focus_only_function',
  boundary_country: 'boundary_country view',
github eslint / eslint / tests / lib / cli-engine.js View on Github external
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

const assert = require("chai").assert,
    path = require("path"),
    sinon = require("sinon"),
    leche = require("leche"),
    shell = require("shelljs"),
    Config = require("../../lib/config"),
    fs = require("fs"),
    os = require("os"),
    hash = require("../../lib/util/hash");

const proxyquire = require("proxyquire").noCallThru().noPreserveCache();

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

describe("CLIEngine", () => {

    const examplePluginName = "eslint-plugin-example",
        examplePluginNameWithNamespace = "@eslint/eslint-plugin-example",
        requireStubs = {},
        examplePlugin = {
            rules: {
                "example-rule": require("../fixtures/rules/custom-rule"),
                "make-syntax-error": require("../fixtures/rules/make-syntax-error-rule")
            }
        },
github noopkat / avrgirl-arduino / tests / avrgirl-arduino.spec.js View on Github external
var test = require('tape');
var proxyquire = require('proxyquire');
var sinon = require('sinon');

// proxyquired connection module
var Connection = proxyquire.noCallThru().load('../lib/connection',
  { serialport: {
    list: function() { return Promise.resolve(
      [
        { comName: '/dev/cu.sierravsp', manufacturer: '', serialNumber: '',
          pnpId: '', locationId: '', vendorId: '', productId: '' },
        { comName: '/dev/cu.Bluetooth-Incoming-Port', manufacturer: '',
          serialNumber: '', pnpId: '', locationId: '', vendorId: '',
          productId: '' },
        { comName: '/dev/cu.usbmodem1421', manufacturer: 'Arduino (www.arduino.cc)',
          serialNumber: '55432333038351F03170', pnpId: '', locationId: '0x14200000',
          vendorId: '0x2341', productId: '0x0043' }
      ])
    }
  },

  SerialPort: require('./helpers/mockSerial').SerialPort
github mozilla / send / test / backend / language-tests.js View on Github external
const assert = require('assert');
const sinon = require('sinon');
const proxyquire = require('proxyquire').noCallThru();

const config = {
  l10n_dev: false // prod configuration
};
const pkg = {
  availableLanguages: ['en-US', 'fr', 'it', 'es-ES']
};

function request(acceptLang) {
  return {
    headers: {
      'accept-language': acceptLang
    }
  };
}
github ipfs-shipyard / ipfs-deploy / test / url-utils.js View on Github external
const test = require('ava')
const proxyquire = require('proxyquire').noCallThru()
const { gatewayHttpUrl } = require('../src/url-utils')

test('get http gateway url for a cid', t => {
  const expected = 'https://ipfs.io/ipfs/fakecid/'
  const actual = gatewayHttpUrl('fakecid')
  t.is(actual, expected)
})

test('get http gateway url for a cid on infura', t => {
  const expected = 'https://ipfs.infura.io/ipfs/fakecid/'
  const actual = gatewayHttpUrl('fakecid', 'infura')
  t.is(actual, expected)
})

test('get http gateway url for a cid on pinata', t => {
  const expected = 'https://gateway.pinata.cloud/ipfs/fakecid/'
github BlinkUX / sequelize-mock / test / queryinterface.spec.js View on Github external
'use strict';

var should = require('should');
var bluebird = require('bluebird');
var proxyquire = require('proxyquire').noCallThru();
var util = require('util');

var ErrorsMock = {
	BaseError: function () {},
	InvalidQueryResultError: function () {},
	EmptyQueryQueueError: function () {},
};
util.inherits(ErrorsMock.BaseError, Error);
util.inherits(ErrorsMock.InvalidQueryResultError, Error);
util.inherits(ErrorsMock.EmptyQueryQueueError, Error);

var QueryInterface = proxyquire('../src/queryinterface', {
	'./errors': ErrorsMock,
});

describe('QueryInterface', function () {
github mozilla / send / test / backend / info-tests.js View on Github external
const sinon = require('sinon');
const proxyquire = require('proxyquire').noCallThru();

const storage = {
  ttl: sinon.stub()
};

function request(id, meta) {
  return {
    params: { id },
    meta
  };
}

function response() {
  return {
    sendStatus: sinon.stub(),
    send: sinon.stub()
github Skellington-Closet / slack-mock / test / mocker / rtm.spec.js View on Github external
'use strict'

const chai = require('chai')
const expect = chai.expect
const sinon = require('sinon')
const proxyquire = require('proxyquire').noCallThru()

chai.use(require('sinon-chai'))

describe('mocker: rtm', function () {
  let rtm
  let wsMock
  let wsServerMock
  let wsClientMock
  let expressMock
  let expressAppMock
  let serverMock
  let loggerMock

  before(function () {
    wsClientMock = {
      send: sinon.stub(),
github zalando-incubator / perron / test / client.js View on Github external
const assert = require('assert');
const proxyquire = require('proxyquire').noCallThru();
const sinon = require('sinon');

describe('ServiceClient', () => {
    let clientOptions;

    const requestStub = sinon.stub();
    const emptySuccessResponse = Promise.resolve({
        statusCode: 200,
        headers: {},
        body: '{}'
    });

    const ServiceClient = proxyquire('../lib/client', {
        './request': requestStub
    });
github travel-and-help / start-kit / src / back / controllers / actions / user.spec.js View on Github external
'use strict';

const proxyquire = require('proxyquire').noCallThru();

describe('user actions service', () => {
    let sut;
    let challengeModel;
    let challengeIds;
    let user;
    let saveResult;

    beforeEach(() => {
        challengeIds = ['id#1'];
        saveResult = 'something has been saved... or not';
        challengeModel = {
            find: env.stub().returns(challengeModel),
            populate: env.stub().returns(challengeIds)
        };
        user = {

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