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
2 answers

how test for no content, while we have 204 NO CONTENT status, as there is no 'Content-Type' header at all?

It's easy to test Content-Type when having a 200 OK status: it('should list All permissions on /permissions GET', (done)=> { supertest(app) .get('/permissions') .expect('Content-Type', /json/) .end( (err, res)=> { …
asedsami
  • 609
  • 7
  • 26
0
votes
1 answer

Runs script repeatedly to api test

I currently have an api test script using supertest + mocha + grunt. I would like to run this script every 1 minute. How is it possible
Rafael C.
  • 2,245
  • 4
  • 29
  • 45
0
votes
1 answer

Supertest mongoose query issue

I am using supertest, mocha and expect for testing my app. I encountered an issue where the document returned is null and there is no error. router.get('/user', function (req, res) { User.findOne({ _id: '56c59bb07a42e02d11a969ae' },…
naz
  • 1,478
  • 2
  • 21
  • 32
0
votes
1 answer

How do I get superagent-hawk to work with supertest

I have an API that I am trying to test. It uses hawk authentication. I have successfully test failure codes using supertest, but I'm not sure how to include the hawk authentication within test script. I have found and installed superagent-hawk,…
Machtyn
  • 2,982
  • 6
  • 38
  • 64
0
votes
1 answer

Mocha supertest integration test exits too soon

I am running the following integration test for a Node.js application. The first API already exists, while the second does not: 'use strict'; var app = require('../..'); import request from 'supertest'; …
giorgiosironi
  • 1,077
  • 1
  • 11
  • 18
0
votes
1 answer

How do I import routes for testing with Supertest?

I have an application tested by Mocha and I'm able to successfully run my tests with what I have now, but I'm explicitly setting a GET route to /api/v1 within my test file. Here's the test file... API.js: var request = require('supertest'); var…
IIllIIll
  • 504
  • 8
  • 25
0
votes
1 answer

Prevent supertest from running until express server has started

I have an node / express js app that was generated using the yoman full stack generator. I have swapped out mongo / mongoose for cloudant db (which is just a paid for version of couchdb). I have a written a wrapper for the Cloudant node.js library…
springdo
  • 43
  • 5
0
votes
2 answers

learning testing in mocha with supertest. can't get test to fail

I am not sure how, but I can not for the life of me figure out how to make this test fail. I honestly don't really know what I'm doing, but seeing as /fail doesn't exist AND all my routes are protected with authentication, which results in a GET…
Dustin
  • 567
  • 2
  • 5
  • 18
0
votes
2 answers

How do I add methods to nodejs supertest module?

I'm trying to add some convenience methods to https://github.com/visionmedia/supertest. So far the only way I was able do it is by adding them directly to the module source code in lib/test.js: Test.prototype.expectHeaders = function (a) { for…
0
votes
2 answers

Mocha- Testing Express API With Global Middleware

This is my first express app and I'm having some trouble writing the tests for the endpoints. At the moment I am not using a database to store the tokens or check for users when logging in. The tests I have written pass, however they are not…
hyprstack
  • 4,043
  • 6
  • 46
  • 89
0
votes
0 answers

Mocha & SuperTest Tests Timing out

I've got a problem whereas sometimes my tests fail due to the asserts being run before the response comes back here in my integration tests: it('should find all countries when no id is specified', co.wrap(function *(){ var uri =…
PositiveGuy
  • 17,621
  • 26
  • 79
  • 138
0
votes
0 answers

Problems sharing object instance with mocha.js

I've been struggling for a couple hours with this problem and I just can't find a solution. Lets say I have this file(main.js) exporting an object: var MyModule = require('./module'); var dependency = require('./moduleDependency'); exports.start =…
Mollo
  • 723
  • 3
  • 7
  • 24
0
votes
1 answer

supertest - res/req is not defined

I'm new to supertest and am trying to figure out a simple task. I have a post request I'm testing, which assigns a userkey like so: app.post('/game/:username', function(req, res){ var image = req.body.image; var userName =…
devdropper87
  • 4,025
  • 11
  • 44
  • 70
0
votes
1 answer

SuperTest - App is not defined

I'm new to test driven development and am trying to use supertest to teach myself. I'm confused as to why I keep getting the error "app is not defined"? It is from my calls to request(app) which I have bolded below. I tried to look up the…
devdropper87
  • 4,025
  • 11
  • 44
  • 70
0
votes
1 answer

Why won't my supertest calls chain?

It never hits the inner call, so done() isn't being called and my Mocha test is timing out. Why is this? testUsers.forEach(function(loggedInUser) { var describeStr; if (loggedInUser && loggedInUser.username === 'a') { describeStr = 'Tangos…
Adam Zerner
  • 17,797
  • 15
  • 90
  • 156