I need to mock client side HTTP requests. I'm using isomorphic-fetch in the client side and I'm using mocha and nock for testing and mocking. All my client requests are based on relative path. Due to this I'm unable to provide host name f...
When I stub request with nock it returns String result instead of Object even with 'Content-Type': 'application/json':  var response = {   success: true,   statusCode: 200,   body: {     "status": "OK",     "id"...
In node.js, I have trouble making superagent and nock work together. If I use request instead of superagent, it works perfectly.  Here is a simple example where superagent fails to report the mocked data:  var agent = require('superagent'); v...
I'm writing code interacting with PayPal classic API. The first part of this interaction is to send request to PayPal and get a token from them. For that I use simple https request:  function makePayPalRequestForToken(options, callback) {  var re...
I've written an asynchronous JavaScript function though do not seem to be getting the returned value I expect.  Could somebody explain if I'm misunderstanding how async functions work or if it's something not quite right my test?  Below i...
Having trouble using Nock.js to mock an HTTP Post Request with csv file attachment.  With superagent this is possible:  authenticatedSession       .post('/foo')       .set('Content-Type', 'multipart/form-data')       .attach(&...
This is how one of my intercept functions looks like now:  interceptWithError() {   nock(baseUrl)     .get(/.*/)     .replyWithError(500);    nock(baseUrl)     .put(/.*/)     .replyWithError(500);    nock(baseUrl)     .post(/.*/)     .replyWithError(...
I'm currently learning RxJS and I'm trying to figure out how to test Observable.ajax() using nock.  Here's my simplified example without any assertions... I just want to see if nock can intercept that API call or not.  import { afterEach,...
I'm using nock to fake out the response from a GraphQL server, however it seems that my nock code isn't being respected, and I can't quite seem to understand why.  What follows is a large chunk of code, but it seems that when I output the...
I am trying to mock a property of an object that acts as an object and as a function at the same time. Here's the code:  index.js  const nock = require('nock');  async myFunc() {   nock.back.setMode('param1');   const { nockDone }...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.