Questions tagged [supertest]

SuperTest is a module that provides high-level abstraction for testing HTTP in node.js, using low-level API provided by super-agent.

SuperTest is a module that provides high-level abstraction for testing HTTP in node.js, using low-level API provided by super-agent.

922 questions
0
votes
1 answer

Why is response coming through in Postman working but not my test?

I have this express controller in order to find the amount of unread notifications, that a user is a recipient of. Here: app.get('/api/user/:uid/notifications/newcount', (req, res, next) => { const firebaseUID = req.params.uid; …
bloppit
  • 621
  • 8
  • 22
0
votes
0 answers

Why isn't commentCount being updated in my test?

I have a Post model and a Comment model. When a user posts a comment, the postID will be sent as a param. Once the comment is saved, it's id will be pushed into the comments array that belongs to the post. The Post model has a commentCount which is…
bloppit
  • 621
  • 8
  • 22
0
votes
0 answers

errors creating test for passport using mocha

I've been working a while on getting a test to work with Mocha and Passport. I tried a couple articles on here, but I can't get them to work. Currently, I have installed supertest and I'm trying that. process.env.NODE_ENV = 'test'; var chai =…
user269964
  • 159
  • 11
0
votes
1 answer

How to save api response in a variable in mocha?

I am calling an api and want to save a particular response value(id) in a variable so that I can use the same id in further test cases. it('1: Valid userId', function (done) { …
Shashi Kumar Raja
  • 508
  • 1
  • 8
  • 23
0
votes
1 answer

koa.js returning 404 "Not Found" after signup, instead of the token from ctx.body

I'm failing to return my token to actually be retrieved from my middlewares using xhr agents say supertest and postman. after I signup my user. I'm trying to get the jwt from body so i can make authenticated requests, but for some reason i keep on…
ArchNoob
  • 3,946
  • 5
  • 32
  • 59
0
votes
2 answers

NodeJS - Supertest throw Error: Can't set headers after they are sent when I use app to test, such as supertest.agent(express())

I use supertest to test my RESTful API which develop by express, but I encountered a problem. The following the debug message. Error: Can't set headers after they are sent. at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11) …
J. Q
  • 1
0
votes
1 answer

Supertest shows passing when it should fail

Here is the output from morgan ::ffff:127.0.0.1 - - [01/Dec/2016:23:44:19 +0000] "GET /temp HTTP/1.1" 404 17 "-" "node-superagent/2.3.0" And the tests that i have written are var chai = require("chai"); var request = require('supertest'); var…
georoot
  • 3,557
  • 1
  • 30
  • 59
0
votes
1 answer

Error: connect ECONNREFUSED , mocha , supertest

I'm new to mocha and supertest , I'm trying to test my API but I always get connection refused error . var request = require('supertest'); it("posts a new comment to /comment", function (done) { var comment = { username: 'riheb',…
Safa
  • 107
  • 2
  • 9
0
votes
1 answer

Sinon - How to stub authentication library (Authy -Twilio)

I am currently new to Sinon, Mocha, Supertest and in the process to writes tests. In my current scenario, i have authentication library which verifies my "OTP" and after verifying it proceeds to do operation within the callback function. I am…
Aditya Patel
  • 569
  • 1
  • 10
  • 28
0
votes
1 answer

How to store the response body for further test case in supertest

I have an API /user/login which returns the token. using supertest and mocha i wrote a test case where it will make a call to '/user/login' and verify that the response has a token or not now i have to store the token for further token for further…
questionar
  • 274
  • 2
  • 18
0
votes
1 answer

Why does my timeout is exceeded?

I'm developing an API with Node.js and Express and i'm using Mocha and Supertest to write unit tests. I have a BIG file of tests which test every route with almost random parameters to see if my error handling works well. Everything was great until,…
Devz
  • 563
  • 7
  • 23
0
votes
1 answer

Looking for Nodejs HTML reporter for automated tests running on Jenins

We run our automated API acceptance tests on Jenkins. They were written in ruby and we're moving them to NodeJS. I'm looking for an HTML reporter plugin for Jenkins that produces reports similar to the nice HTML reports produced by…
0
votes
1 answer

expected "location" header field - using mocha with supertest in node.js

I am not using express,instead i m using koa js 1.0. Here is a sample app for inserting user. It includes mocha with supertest for test purpose. In app.js -> var koa = require('koa'); var app = koa(); var routes = require('koa-route'); //routes var…
Rasika
  • 1
  • 1
0
votes
1 answer

Jasmine `expect` never wrong in superagent `end`

My code doesn't do what it should. All the Jasmine expect() that are in a supertest end() callback function pass, even if they should not. const app = require('../server') const request = require('supertest') describe('Client', function() { const…
SteeveDroz
  • 6,006
  • 6
  • 33
  • 65
0
votes
2 answers

Why does mocha timeout when used with restify and knex?

I'm presently using mocha 2.5.3, supertest 2.0.0, knex 0.11.10, restify 4.1.1 and sqlite3 3.1.4. I have the following very simple restify server: const restify = require('restify'); const knex = require('knex')({ client: 'sqlite3', connection:…
user2250201