How to use the proxyquire.callThru 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 9technology / meta-props / test / meta-props.spec.js View on Github external
import test from 'ava';
import { jsdom } from 'jsdom';
import sinon from 'sinon';
import proxy from 'proxyquire';
import camelcase from 'camelcase';

const sandbox = sinon.sandbox.create();
const castStub = sandbox.stub().returnsArg(0);
const camelSpy = sandbox.spy(camelcase);

proxy.noCallThru();
const metaProps = proxy('../src', {
    camelcase: camelSpy,
    './cast': castStub,
}).default;
proxy.callThru();

const doc = jsdom();
global.document = doc;

sandbox.spy(doc.head, 'querySelectorAll');
sandbox.stub(console, 'warn');

test.beforeEach(() => {
    sandbox.reset();
    doc.head.innerHTML = ''; // reset meta tags
});

test('no props returns empty object', (t) => {
    t.deepEqual(metaProps(), {});
});
github LeanKit-Labs / cowpoke / spec / behavior / environment.spec.js View on Github external
require("../setup");
const proxyquire = require("proxyquire").callThru();
const Promise = require("bluebird");
const util = require("util");
const _ = require("lodash");
/* global expect */


const env = {
	name: "test",
	baseUrl: "http://example.com",
	_id: "VoKtrtXdqRS3VDAV",
	image: "helloworld",
	key: "key",
	secret: "secret",
	slackChannels: channelsList
};
github LeanKit-Labs / cowpoke / spec / behavior / stack.spec.js View on Github external
require( "../setup" );
const proxyquire = require( "proxyquire" ).callThru();
const Promise = require( "bluebird" );
const util = require( "util" );
/* global */

const envId = "101";
const stackId = "202";
const stack = {
	id: stackId,
	type: "environment",
	links: {
		self: util.format( "/v1/projects/%s/environments/%s", envId, stackId ),
		account: util.format( "/v1/projects/%s/environments/%s/account", envId, stackId ),
		services: util.format( "/v1/projects/%s/environments/%s/services", envId, stackId ),
		composeConfig: util.format( "/v1/projects/%s/environments/%s/composeconfig", envId, stackId )
	},
	actions: {
github LeanKit-Labs / cowpoke / spec / behavior / rancher.spec.js View on Github external
require( "../setup" );
const proxyquire = require( "proxyquire" ).callThru();
const baseURL = "http://myRancher.com";
const util = require( "util" );
const _ = require( "lodash" );
const envId = "l0l";
const environmentsBody = [ {
	id: envId,
	name: "Test",
	state: "active", // not mentioned in docs
	links: {
		environments: `${baseURL }/v1/projects/${envId}/environments`,
		containers: `${baseURL }/v1/projects/${envId}/containers`,
		services: `${baseURL }/v1/projects/${envId}/services`,
		stacks: `${baseURL }/v1/projects/${envId}/environments`
	}
} ];
const stackId = "2a2";
github LeanKit-Labs / cowpoke / spec / behavior / dockerhub.spec.js View on Github external
require( "../setup" );
var proxyquire = require( "proxyquire" ).callThru();
var when = require( "when" );
var nock = require( "nock" );
var urlencode = require( "urlencode" );
var rp = require( "request-promise" );
var namesapce = "leankit";
var name = "cowpoke";
var tagToCheck = "tag1";
var validImage = namesapce + "/" + name + ":" + tagToCheck;
var invalidImage = namesapce + "/" + name + ":DNE";
var dockerhub = proxyquire( "../../src/dockerhub", {
	"./util": {
		getImageInfo: function( image ) {
			if ( image === validImage ) {
				return {
					docker: {
						repo: namesapce,

proxyquire

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

MIT
Latest version published 5 years ago

Package Health Score

62 / 100
Full package analysis