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

Supertest/mocha done parameter passed within tests

Below is the code that I wrote with mocha, chai and supertest. I have a question with regards to the segment of code below that works, with focus on token. describe('Authenticated userTest', function () { var token; before(function…
Luna
  • 73
  • 1
  • 1
  • 7
0
votes
2 answers

Supertest .expect(200) vs. res.status.should.equal(200);

Do both of these serve the same purpose? Why are they both used in, for example, this tutorial https://codeforgeek.com/2015/07/unit-testing-nodejs-application-using-mocha/ ? Edit, Looking at the following code: var supertest =…
Charles Chen
  • 3
  • 1
  • 4
0
votes
1 answer

Using curl command to make a supertest/superagent call

curl -k https://myserver/api/v1/rptoken --cert user.pem --key user.key -H "Content-type: application/x-www-form-urlencoded" -X POST -d "name=foo&name=bar" I want to use the above curl call to verify the status code as well as catch the entire…
shanwar
  • 319
  • 1
  • 2
  • 19
0
votes
0 answers

Can't find user through ID

I can't find a user through ID in the end method. However I can find a user outside the it method. But then I can't use the res.body._id variable to give it as a argument to the find method. Below you can see my code: describe("A user registers",…
superkytoz
  • 1,267
  • 4
  • 23
  • 43
0
votes
1 answer

supertest-as-promised and chai

I try to use supertest-as-promised with chai's expect. The test should go like this: post some JSON the foos endpoint, then call bars endpoint, where the response's body has a length of 2. it('should fail', function(){ var agent =…
user3568719
  • 1,036
  • 15
  • 33
0
votes
1 answer

koa/supertest hangs on multiple post requests

As mentioned im trying to do multiple post requests on a koa server with supertest. As you can see in the code below. When the script is executed via DEBUG=koa* mocha --harmony_destructuring --sort --require co-mocha --timeout 0 "test.js" it just…
cdx
  • 99
  • 8
0
votes
2 answers

Can't get objects to be equal

I'm getting the following fail message from Mocha: Uncaught AssertionError: expected Object { name: 'John Doe' } to be Object { name: 'John Doe' } + expected - actual Here is my test code: describe("A user gets registered", function () { …
superkytoz
  • 1,267
  • 4
  • 23
  • 43
0
votes
1 answer

Mocha: using it-each with dependent variables

So I've been having some trouble with the it-each module for loop testing in mocha. I'm using supertest, should and it-each modules. var hasAccess = [{endpoint: "announcements", send: {"creator": users}}] users is my varibale which is assigned in…
Delonous
  • 201
  • 2
  • 5
  • 11
0
votes
1 answer

How do I write a mocha test with a result array?

I'm attempting to write a mocha test dynamically, rather than write an expect for each item in a res.body.result. I have a json response like this: { "ok": true, "result": { "year": "2000", "makes": [ "Acura", "Audi", …
Christina Mitchell
  • 437
  • 2
  • 8
  • 17
0
votes
1 answer

IntegrationTest with SuperTest expects 302 gets 200 in Sails.js application

I'm trying to write a simple Test for my Controller. I use this documentation from Sails.js The UserController.test.js: var request = require('supertest'); describe('UserController', function () { describe('#login()', function () { …
Suisse
  • 3,467
  • 5
  • 36
  • 59
0
votes
1 answer

Code from beforeEach running after the 'it'spec

I'm using mocha and supertest to test a REST service. In this case, I need to test that a subsequent login after a GET request returns the query from that GET request. login user perform GET request on endpoint(s) using params login user and expect…
Machtyn
  • 2,982
  • 6
  • 38
  • 64
0
votes
1 answer

How to send a authentication with a request with supertest

I'm trying to test a authenticated route. This is my code: let request = require('supertest'); var superagent = require('superagent'); var agent = superagent.agent(); var theAccount = { name: '*********', role: 'admin', id:…
stijn.aerts
  • 6,026
  • 5
  • 30
  • 46
0
votes
1 answer

Mocha test error CSRF token mismatch

I recently learning how to write tests with mocha and supertest. When I try to testing a post url, it require _csrf property, so I check this [How to test express form post with CSRF? ]1 and put the following code var request =…
lugy90
  • 81
  • 1
  • 5
0
votes
0 answers

Mocha/SuperTest/Request Interaction Inconsistency - request.defaults is not a function

This one has me stumped. I'm using mochajs as a test suite for a NodeJS (Express 4) application. The test suite runs through a series of mocha files, all using a pretty similar set up,and when run individually they all run fine - but when run as a…
SuperSephy
  • 115
  • 2
  • 9
0
votes
3 answers

Running Travis-CI using MochaJS, Supertest w/ Babel, Browserify, and Gulp

I've followed some tutorials and web casts on code school, mainly those on Node, ES2015, Angular, and Express. I've started a little project of my own and I've implemented all of the above. I'm also trying to get automated builds and testing working…
gh0st
  • 1,653
  • 3
  • 27
  • 59