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

timeout error when testing promises with supertest-as-promised and mocha

so i am trying to test a function as below function generateJwt(){ var deferred = Q.defer(); deferred.resolve({ message: 'user created', token: signedJwt, userId: user.userId …
user3137376
  • 1,527
  • 2
  • 19
  • 29
0
votes
1 answer

Supertest + Tape + Restify - Can't set headers twice error on consecutive calls

I'm building an API using Node.js and Restify. I am trying to do functional endpoint testing using Supertest and Tape. I have a test that makes two consecutive calls to the API and it is saying that I can't set the headers after they are sent.…
evcohen
  • 225
  • 1
  • 2
  • 8
0
votes
1 answer

Run test are not running as expected

I run the following test and its not stopping in the actions of the express router The URL is exactly the url which I put in postman and works ,any idea? describe('test', function () { it('Should Run///', function (done) { …
user4445419
0
votes
2 answers

.end() function not entered when using async

I am using supertest with async to test some websites. When I execute the test with mocha, the end function is not entered. I added some logging to the end function but it isn't printed. When I remove the async.each, the end function is entered…
Homewrecker
  • 1,076
  • 1
  • 15
  • 38
0
votes
1 answer

Stubbing a constructor of a third party library when testing express app with Supertest

I've got a simple express app that looks like this: var SendMandrillTemplate = require('send-mandrill-template'); var sendMandrillTemplate = new SendMandrillTemplate('api-key-goes-here'); var app = require('express')(); app.get('/', function(req,…
Alex
  • 37,502
  • 51
  • 204
  • 332
0
votes
1 answer

Object is not a Function - SuperTest

I'm not sure why it's throwing this error and what exactly it's saying is not a function. 'use strict'; var koa = require("koa"); var app = koa(); var chai = require('chai'); var expect = chai.expect; var request =…
PositiveGuy
  • 17,621
  • 26
  • 79
  • 138
0
votes
1 answer

How to assert validation errors of mongoose using supertest?

I am trying to validate using supertest that the response returned by a REST endpoint contains the validation error of moongose validation which looks like below errors: Object { firstName: Object { kind: 'required', message: 'Path…
Suhas
  • 7,919
  • 5
  • 34
  • 54
0
votes
1 answer

Error: timeout of XX ms exceeded. Ensure the done() callback is being..supertest+express()

I am trying to test apis for my node server(using express) via mocha+supertest. I have a post API like in my app.js as : app.post('/product/createProduct',routes.createProduct); In routes, this api looks like: functions.createProduct =…
Ankit Khare
  • 99
  • 2
  • 11
0
votes
2 answers

Using supertest and co to validate database content after request

I want to write a test to update a blog post (or whatever): * Insert a blog post in a database * Get the id the blog post got in MongoDb * POST an updated version to my endpoint * After the request have finished: check in the database that update…
Marcus Hammarberg
  • 4,762
  • 1
  • 31
  • 37
0
votes
0 answers

meanjs routes tests not working

I am using the meanjs 0.4.0 branch. And while performing the routes tests it gives the error timeout of 2000ms exceeded. The error comes from this code: before(function(done) { var app = express.init(mongoose); agent = request.agent(app); …
bring2dip
  • 886
  • 2
  • 11
  • 22
0
votes
0 answers

Sails application connecting to MySql / PgSql error

In my Sails application I have some integration tests in Mocha/Chai/Supertest that run against sails-disk database until today. Today I tried switching to actual databases, to test performance and behaviour as well as reliability of my models.…
Vee6
  • 1,527
  • 3
  • 21
  • 40
0
votes
2 answers

Getting "TypeError: object is not a function" when using supertest/superagent in forEach loop

I'm using supertest to test a set of URLs by the same rules. var urls = [ "https://www.example.com", "https://www.example2.com" ]; urls.forEach(function (url) { console.log('begin'); request = request(url) .get('') …
priktop
  • 1,155
  • 3
  • 12
  • 30
0
votes
1 answer

Created rest ressource in Hapijs

I'm building a node REST API server built with hapi.js, for a CRUD ressource, and for the Ressource creation, I want to set the location header and status code using created rather than code(201).header('location.... According the current API…
AdrieanKhisbe
  • 3,899
  • 8
  • 37
  • 45
0
votes
0 answers

Mocha Chai Sinon SuperTest: Node function with callback which is incorrectly stubbed causes test to pass

I ran into an issue today where I had passing tests that should have failed. There were some incorrectly stubbed methods using Sinon that failed to stub out the callback correctly. I would have expected execution to fail, but it passed the test,…
josiah
  • 1,314
  • 1
  • 13
  • 33
0
votes
0 answers

Nodejs Supertest Object is not a function error

In a shell script execution callback, I'm sending a POST request to a service, but for some reason I get Error: [TypeError: object is not a function]. This is my code: exec('./scripts/update.sh', function(err, stdout, stderr) { if (!err) { …
Ilan Biala
  • 3,319
  • 5
  • 36
  • 45