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'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...
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 am trying to nock an axios request. I have successfully mocked the POST request, but it is sending an OPTIONS preflight request. However, I am getting the following error and not sure what to make of it.  Error: Headers Authorization forbidden...
I have a Node application that connects to the Twitter REST and streaming APIs. In order to test code that makes requests to the REST API, I can use Nock to intercept the HTTP request and return mock data like so:  var nock = require('nock')...
I have the following code:  var request = require('superagent'); var nock = require('nock') var scope = nock('http://localhost:80', {     reqheaders: {         'Content-Type': 'text/html'     } }); scope.post(&...
In the Writing Tests section of Redux, how does the store.dispatch(actions.fetchTodos()) not invoke the fetch method, if store.dispatch is literally calling actions.fetchTodos?  it('creates FETCH_TODOS_SUCCESS when fetching todos has been done...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.