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

How to do Integration tests NodeJS + Firebase Admin?

I'm trying to write some integration tests on NodeJS with Firebase (firebase-admin, with the test library jest and supertest), and some tests are failing randomly when I run all my tests. Separately, my tests are passing, but it seems like when too…
Julien Mazars
  • 1,032
  • 11
  • 24
0
votes
1 answer

Testing with Mocha and Super test: Uncaught error outside test suite

While testing my api endpoints using mocha and supertest I got some of my test passing and some are not. The error message I got was uncaught error outside test suite: Uncaught error: listen EADDRINUSE:::5000
0
votes
3 answers

Converting Mocha api test from async await to Supertest

i have following question, i start writing API test, now it's look like: xit('should add address ', async () => { const result = await request({ headers: Object.assign(config.headers, { 'Authorization': 'Bearer '+auth_token }), …
0
votes
1 answer

Using sinon fakeTimer with supertest lead to an error

When I use sinon fakeTimer with supertest, it leads to an error Error: socket hang up. Why and how to fix it, pls help ?
0
votes
1 answer

MochaJS - Reuse block in other files

Currently I'm using SuperTest to test an API and to each request I need to get the access token from admin user, so I created this request (works fine): authenticate.js const request = require('supertest'); var storeAccessToken; describe ('POST…
Rafael C.
  • 2,245
  • 4
  • 29
  • 45
0
votes
1 answer

Sinon Spy not called but original function is called

My spy is not being called, even though I can see the console log in the original function getting called Mocha test: const { expect } = require('chai'); const supertest = require('supertest'); const MyController =…
user123
  • 99
  • 1
  • 11
0
votes
2 answers

Sending url-encoded parameters in a superagent GET request

With curl I can send GET-requests with url-encoded parameters as follows: curl -G http://example.com --data-urlencode "key=val" How do I do this with supertest / superagent? So far I've tried things like const response = await request(app) …
jorgen
  • 3,425
  • 4
  • 31
  • 53
0
votes
1 answer

Testing POST with supertest still creates new document

I have written a service called bookService and am currently having the issue that whenever I test a POST request in Hapi (v17) using Supertest and Expect, the test is creating a new record in the database, so it's not actually wrapping the…
0
votes
1 answer

Using Pa11y with Supertest

What is the best way to use Pa11y with Supertest? Something like: describe ('my page', function () { it ('is accessible', function () { request (server).get ('/').expect (function ({ body }) { // How to run Pa11y here? …
Danyal Aytekin
  • 4,106
  • 3
  • 36
  • 44
0
votes
0 answers

Supertest - Save response object for later use in other testcases

I am trying to create a helper function to create some token and use it in other functions. In the below functions: I intend to return the token and then print it. But it is printing before completing the function and hence there is not output. Not…
aby
  • 95
  • 1
  • 11
0
votes
1 answer

Is it possible to use query key parameter as variable?

Normally one can query in the following way: .query({ key1: value1, ... keyN: valueN }) But can I use instead of "hard" key values variables? like following: .query({ varKey1: value1, ... varKeyN: valueN …
Alex
  • 362
  • 1
  • 5
  • 14
0
votes
1 answer

What does app.listen look like when using npm start

So this is what I was doing before I exported the app variable so I can perform unit and integration testing for node/express app app.js //app.listen(3000, () => console.log('Example app listening on port 3000!')) module.exports = app; Now How do…
Rod
  • 14,529
  • 31
  • 118
  • 230
0
votes
1 answer

How to prevent ava displaying long objects when a test fails

Given: Express app, AVA, supertest When: I test generated html in response and the test case fails Then: AVA displays the whole response object in the console which slows down analysis of the issue Example of the test: test('Positive case: book is…
Sergiy Seletskyy
  • 16,236
  • 7
  • 69
  • 80
0
votes
1 answer

Mocha dynamic test generation with dynamic data generation

I have created a method called testLoginFailed let testloginFailed = (app, title, data) => { it(title, function (done) { request(app) .post(apiEndPoints.auth.login) .send(data) .then((response) => { …
Varun Sukheja
  • 6,170
  • 5
  • 51
  • 93
0
votes
1 answer

Error: done() invoked with non-Error: {"req":{ ......} request done without error, but test didn't pass

I'm trying to resolve my test but nothing seems to work. Currently I'm using mocha, supertest and chai, but even if request was performed successfully, I'm seeing this annoying error I can't get rid of: done() invoked with non-Error: {“req”:{ …}…