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 - how to create new record with POST, then get it back GET - async series

I have a test that creates a new "municipality" record with a POST call to an API... then in the same test, I want to GET it back and see if it was created successfully. The problem is, I think it's getting it back too fast (before the record was…
user952342
  • 2,602
  • 7
  • 34
  • 54
0
votes
2 answers

Unable to send authenticated request in tests using Jest, Supertest, Passport, Koa2

Despite my best attempts to correctly write test code to authenticate a request agent in Setup blocks or previous describe/it blocks, any request I make from the agent in subsequent describe/it blocks never completes as 200. Example code: const…
internetross
  • 143
  • 2
  • 10
0
votes
1 answer

TypeError: app.address is not a function even though I am exporting my server

I am getting the TypeError shown in the title while trying to run unit tests on my express routes I found 3 other questions like this, but the solutions to those do not solve my issue. I need some other possible solution. The Error ? Compliance…
Danny Ellis Jr.
  • 1,674
  • 2
  • 23
  • 38
0
votes
2 answers

Why error message is displayed on console when controller throws a method supertest

I am writing integration test for a nodejs/sails js application, where I have an Async controller method/route that throws error when input parameters are not provided. I am using supertest to write integration test, everything works fine from my…
Saroj
  • 1,551
  • 2
  • 14
  • 30
0
votes
1 answer

Mocha test failing when sending invalid data to the server

I'm working on a small todos app with nodejs and mongodb. I have the model definition here: const Todo = new Schema({ text: { type: String, require: true, minlength: 5, trim: true }, completed: { …
CodeTrooper
  • 1,890
  • 6
  • 32
  • 54
0
votes
1 answer

how to run superserver on localhost?

Very close to using superset on windows 10. How do I configure superset to run on 127.0.0.1 instead of 0.0.0.0? (Python34) E:\Miniconda3\Scripts>fabmanager run --app superset 2018-02-24 15:25:59,755:INFO:werkzeug: * Restarting with stat …
user1878647
  • 131
  • 1
  • 7
0
votes
0 answers

Node.js e2e test strategy - Dependency Injection of config object

I am using DI to inject config object into classes. In one end-to-end test I have scenario where I need to compare results of two requests - one with original config and another with modified config object. I do not want to overwrite global config…
Angelina
  • 1,473
  • 2
  • 16
  • 34
0
votes
1 answer

Use different file for testing in node js

I am using a particular set of URLs for connecting to services. They are there in the config.js file. Now while testing using mocha, I want to use a different set of urls. Is it possible to over-ride the urls configured in the js file from the test…
user3276247
  • 1,046
  • 2
  • 9
  • 24
0
votes
2 answers

Why does npm test return TypeError: app.use() requires a middleware function when server gets passed to it?

I am attempting to write some simple tests for my backend, and I am following a tutorial where a very similar code functions, while mine does not (he gets no complain about his app.use()). Why does it throw TypeError: app.use() requires a middleware…
Roxcly
  • 146
  • 3
  • 18
0
votes
1 answer

Mocha supertest isn't POSTing data

My test looks like: const request = require('supertest-as-promised') const app = require('../app') describe("Basic Authentication with JWT", () => { it('Should login properly', function () { return request(app) .post('/login') …
Shamoon
  • 41,293
  • 91
  • 306
  • 570
0
votes
0 answers

response is undefined, sometime, with testing Express using supertest and jest

This is my test: const request = require('supertest'); const makeRestController = require('../main/controller/restController'); const userRepository = { getCount: async () => { return 2; } }; const logger = { info: () => { …
dierre
  • 7,140
  • 12
  • 75
  • 120
0
votes
1 answer

How to get swaggerize-express to ouput input validation information

I'm setting my Node.js project with swaggerize-express, and are currently testing my backen using supertest to test my backend. When I run the supertests, and it fails due to swagger rejecting (i.s. input validation fails) the data I pass to it,…
kenneho
  • 401
  • 1
  • 7
  • 24
0
votes
1 answer

Error when trying to read JSON array using Should, Mocha, & Supertest

I have the following JSON payload: "app": { "name": "myapp", "version": "1.0.0", "last_commit": { "author_name": "Jon Snow" "author_email": "my@email.com" } } and the following .js file (using Mocha, Supertest and…
TheAuzzieJesus
  • 587
  • 9
  • 23
0
votes
1 answer

Supertest Error: expected '[]' response body, got '[""]'

I'm not sure why I keep getting this error. Whenever I run npm test I get this full error: 1) Listing subscriptions on /subscriptions Returns initial subscriptions: Error: expected '[]' response body, got '[""]' at error…
0
votes
1 answer

supertest and checking DynamoDB before and after using await

I'd like to test my koa API routes using supertest and check what's in DynamoDB before and after to make sure that the end point did what was intended. // app related const pool = require('../../src/common/pool'); const app =…
SomeGuyOnAComputer
  • 5,414
  • 6
  • 40
  • 72