Questions tagged [superagent]

410 questions
1
vote
1 answer

Testing Auth0 API Patch Request

Trying to test Auth0 API patch request to modify user_metadata. Using mocha and superagent for testing. Get succeeds, but doing a patch with a userid and sending .send({ "metadata": { "nickname": "Jill" } }) in the mocha testing file does not…
oppnahar
  • 81
  • 1
  • 10
1
vote
0 answers

mocha-webpack unit test with superagent

I use mocha-webpack for unit test an external api and I use superAgent for my ajax request. I make 2 test: const request = require("superagent"); var chai = require('chai') , expect = chai.expect , should = chai.should(); var…
Seb
  • 404
  • 2
  • 4
  • 14
1
vote
1 answer

stop superagent after receiving first byte (to only get redirect url)

I'm using superagent (although willing to user other node lib) with the goal to solely get the redirected url, but not the body. The latter is overkill and I want to prevent my code to download the body if I can help it. I cannot use HEAD requests…
Geert-Jan
  • 18,623
  • 16
  • 75
  • 137
1
vote
0 answers

Trouble posting file to a server using superagent

This may be a basic question, but I haven't been able to find the solution anywhere so hopefully it will be helpful to others. I have created a React.js application that I want to use to upload a file to the development server I am running using…
xm33
  • 11
  • 3
1
vote
2 answers

Is there a way to overcome lag between changes in OneNote client and API results?

Changes in OneNote client aren't immediately reflected in apigee. For example: Renaming a section in OneNote client. Apigee shows the old name. Adding a section and adding notes to that section in OneNote; these aren't reflected in my app that uses…
komplexb
  • 79
  • 2
  • 9
1
vote
1 answer

Unit Testing redux async function with Jest

I'm pretty new to unit testing so please pardon any noobness. I have a file api.js which has all the API call functions for the app. Each function returns its promise. Here's how it looks: api.js const api = { getData() { return superagent …
Ateev Chopra
  • 1,026
  • 2
  • 15
  • 32
1
vote
2 answers

Mocha tests using superagent + promises timeout rather than fail with 'expect'

I'm using mocha to run a number of integration tests against an external web service. I use superagent-promise for the request/response handling, and I'm using expect as my assertion library. For some of these tests I need to chain a large number of…
Craig Otis
  • 31,257
  • 32
  • 136
  • 234
1
vote
0 answers

make post request by using superagent, it sent out as get

I made a post request by using superagent: var postUsage = function(postUsage_CB) { var expectedStatusCode = 201; var timeStart = new Date(); request .post(serviceEndPoint) .send(object) .end(function(err, res)…
Qian
  • 11
  • 1
  • 3
1
vote
1 answer

PUT with 'superagent' module

Reading Superagent documentation, There is no distinguish between POST & PUT request : request.post('/user') .set('Content-Type', 'application/json') .send('{"name":"tj","pet":"tobi"}') .end(callback) How to do PUT request using this…
Abdennour TOUMI
  • 87,526
  • 38
  • 249
  • 254
1
vote
0 answers

Unable to post file to server using superagent

I have a react application (using webpack and running on localhost) and I am trying to send a text file to a server that I created separately, still locally using Node.js (also on localhost but different port). For file upload, I use a library…
Adam Loh
  • 111
  • 1
  • 9
1
vote
0 answers

Mimic Ajax requests with Superagent

I'm using Supertest (and thus Superagent) for some API testing on a Node.js project. I have a particular route that returns different content based on the type of request. Using expressJS's req.xhr, the code will return JSON if true or issue a…
Matt Molnar
  • 2,412
  • 3
  • 22
  • 28
1
vote
1 answer

Piping readable stream using superagent

I'm trying to create a multer middleware to pipe a streamed file from the client, to a 3rd party via superagent. const superagent = require('superagent'); const multer = require('multer'); // my middleware function streamstorage(){ function…
cat-t
  • 1,346
  • 1
  • 18
  • 34
1
vote
0 answers

How can I test whether an email was sent using mocha?

I'm using NodeJS (specifically the SailsJS framework), and am sending an email upon creating a user. I want to verify in a Mocha test case that creating a user sends an email. I can include something in the JSON response that states whether an…
Nikhil
  • 91
  • 1
  • 8
1
vote
5 answers

Formatting the string result of text()

Good day, do anyone know how to format or add some extra string (like a comma),to the results given by text()? I am using it in web scraping. Here's the snippet of the scraper: var makeupCatBrand =…
user6359350
1
vote
1 answer

Cannot abort superagent in React app

I am refactoring some code in a React app I've built to make ajax requests to the Tumblr api with superagent instead of jQuery. Note that when using coffeescript @ is equivalent to 'this'. My jQuery ajax call to the tumblr api is as follows: App =…
satyrsynth
  • 399
  • 1
  • 4
  • 14