Questions tagged [proxyquire]

Questions regarding proxyquire - Proxies nodejs's require to make overriding dependencies during testing

Documentation: https://github.com/thlorenz/proxyquire

116 questions
0
votes
0 answers

Not able to mock S3 download request using proxyquire

const awsSdk = require('aws-sdk'); module.exports = { downloadFile(bucketName, fileName, callback) { var s3 = new awsSdk.S3(); var params = { Bucket: bucketName, Key: fileName }; var file =…
iAviator
  • 1,310
  • 13
  • 31
0
votes
1 answer

Require not behaving as expected

I'm using the proxyquire library, which mocks packages on import. I'm creating my own proxyquire function, which stubs a variety of packages I use regularly and want to stub regularly (meteor packages, which have a special import syntax): //…
Florian Bienefelt
  • 1,448
  • 5
  • 15
  • 28
0
votes
1 answer

proxyquire not stubbing method call

I'm trying to use proxyquire to replace a method call within a module I'm testing, but it is calling the method as is despite the fact I have the stub set up. What am I doing wrong? formsReducer.test.js: import { expect } from 'chai'; import * as…
kibowki
  • 4,206
  • 16
  • 48
  • 74
0
votes
0 answers

Unit test Vuejs with Karma, Browserify and Proxyquireify throwing errors

I've been using the vue-cli browserify template and have been doing some unit testing. However I can't get proxyquireify to work. If you look in the tests folder there is a test there that references this file to test with mocks. However whenever I…
Matt Sanders
  • 370
  • 2
  • 12
0
votes
1 answer

Node.js stubbing request.get() to call callback immediately

I'm trying to test a function which calls request.get() function inside it. What I'm trying is to cover all branches of the callback function. I'm trying to achieve it without separating the callback function to a different function because it's…
Jorayen
  • 1,737
  • 2
  • 21
  • 52
0
votes
0 answers

Mock an anonymous function using proxyquire with Node.js?

Is it possible to mock an anonymous function using proxyquire with Node.js? I have a module I need to mock whose constructor is an anonymous class. Is it possible to use proxyquire to mock this, or is there another way to do this? The reason I'm…
arjun
  • 103
  • 1
  • 10
0
votes
2 answers

How to stub object's property, not method?

I have a file config.js with the below code in it: module.exports: { development: { switch: false } } I have another file bus.js with the below code in it: var config=require('config.js'); getBusiness:function(req,callback){ …
Prajwal
  • 321
  • 2
  • 4
  • 21
0
votes
1 answer

Require and import finds module, but proxyquireify does not?

As the question states, the requiring/importing of the module works fine in these cases: const Session = require('../session.js').default; or import Session from '../session.js'); But I want to replace a module that is required inside session.js,…
0
votes
1 answer

react-dnd + proxyquire -> Invariant Violation: Could not find the drag and drop manager in the context MyComponent

I've been using proxyquire to stub out sub-components and stores but ran into an Invariant Violation with components that are wrapped in react-dnd contexts. Warning: Failed Context Types: Required context dragDropManager was not specified in…
0
votes
1 answer

Mock 'end' signal from emitter, but it doesn't get called

I am doing a unit testing with mocha + unit.js + proxyquire. Right now I am stuck at mocked emitter. First mocked emitter which is a fake on 'row' signal, it done. Second one I followed the same like first one. Since it is not a big difference, but…
joe
  • 8,383
  • 13
  • 61
  • 109
0
votes
0 answers

proxyquire not finding module

I have the following code which I am trying to test. However proxyquire cannot find the readDirectory.js. Does anyone understand why? It's returning the following error, Error: Cannot find module '../readDirectory.js' and point to the line were…
hyprstack
  • 4,043
  • 6
  • 46
  • 89
1 2 3 4 5 6 7
8