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 supertest returning an error when everything passes?

My test looks like: it('should create a user with an email address and password', function(done) { return request.post('/v1/users').send(defaultUser).expect(200).expect(function(res) { console.log(res.body); …
Shamoon
  • 41,293
  • 91
  • 306
  • 570
0
votes
2 answers

Avoiding Mocha timeout on assertion error with SuperTest?

I have some Sails.js API tests (using Mocha) that make use of SuperTest's .end() method to run some Chai assertions on the response. I call the test's done() callback after the assertions, but if an assertion error is thrown, the test times out. I…
blah238
  • 1,796
  • 2
  • 18
  • 51
0
votes
1 answer

Unit test with rollback on express

Hi I´m trying to make a unit test creating some fake data and executing a request (using supertest) to check if the controller works well. The problem rise up when the controller tries to get the fake data, because it exists only inside the…
juanmorschrott
  • 573
  • 5
  • 25
0
votes
1 answer

Gruntfile to run app and mock test from single grunt command

I have a Node.js Express REST API app that works. Good. I have a Mocha/Chai/Supertest mock that tests the API app above. Good. But I have to start the app and then independently run the mock test. How can I run a single grunt command that starts…
jfathman
  • 788
  • 3
  • 8
  • 13
0
votes
1 answer

agent.auth before each test in a describe block

The following works: describe('My App', function() { describe('when logged in', function() { it('should allow registered user to make a thing', function(done) { agent.post('/make-a-thing') .auth('testusername', 'validuserpass') …
000
  • 26,951
  • 10
  • 71
  • 101
0
votes
1 answer

asserting response body is empty

I'm trying to assert if response body is empty, but got error: var api = supertest(TEST_URL); ... api.get('..') .expect('Content-Type', /json/) .end(function (err, res) { if (err) { return done(err); } …
hellboy
  • 1,567
  • 6
  • 21
  • 54
0
votes
1 answer

request hangs on sails error

If you make a request to sails via supertest, the response hangs if you return an error. Here, we have already lifted sails, and will run this as an integration test against a live db. var sails = require('sails').lift(); var request =…
aclave1
  • 1,680
  • 18
  • 29
0
votes
1 answer

supertest nodejs test get call

I'm building an API and I'm trying to test it with mocha and supertest. I'm correctly testing a POST call with this code: it("Should generate a PDF based on the given data using API", function(done) { request(app) …
Fez Vrasta
  • 14,110
  • 21
  • 98
  • 160
0
votes
1 answer

expressjs 4.x and https, generate key and certificate

I want to create an https server with express 4.x. Even if a lot of code found on google is based on express 3.x I think I made the port correctly. Even if I tried to goole it is not very clear to me how to generate the keys. Without the key I'm…
nkint
  • 11,513
  • 31
  • 103
  • 174
0
votes
1 answer

What's wrong with my mocha test?

I have written this code in express.js and mongoose routes.js var mongoose = require('mongoose'), logger = require('../logger'); mongoose.connection.on('error', function(){ logger.info('Mongoose connection error' +…
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373
0
votes
1 answer

mocha and supertest.agent not working as expected

I'm trying to write some tests where I need to authenticate first. If I make multiple requests in "before()" I get connection refused. If I split it between "before()" and "it()" it works but I cannot acheive what I want. Code I want to work: var…
Simon
  • 5,158
  • 8
  • 43
  • 65
0
votes
1 answer

Using supertest to test separate nodes run by naught

I'm using a naught (https://github.com/andrewrk/naught) to run my node.js app on multiple cores and also have naught giving me zero downtime deploys with only one machine. I'd like to use supertest (https://github.com/visionmedia/supertest) for…
0
votes
1 answer

Testing random values with mocha/supertest

I have this KoaJS application that is serving an API and I am using mocha/supertest to test the API. One of the tests is to make sure that you can create an oauth token through the API. The test looks like this: it('should be able to create a…
ryanzec
  • 27,284
  • 38
  • 112
  • 169
0
votes
1 answer

connect ECONMREFUSED when using MOCHA to SUPERTEST an express app

I am using MOCHA to test some express framework code. I have written a simple MOCHA code to test messages returned in the response header. The code works. It also means that I am connected to the server and I can get the file from the database.…
user2886680
  • 61
  • 3
  • 9
0
votes
1 answer

Testing express routes with mocha - cannot store request in a variable

Can someone explain to me why the following happens.. I have a code which tests express routes: request = require 'supertest' express = require 'express' app = express() Authentication =…
radical_edo
  • 934
  • 2
  • 11
  • 29