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
-1
votes
1 answer

How to solve ● TCPWRAP or ● TCPSERVERWRAP issues with Express and Supertest

I encountered these ● TCPWRAP or ● TCPSERVERWRAP while trying to run a test on ExpressJs using Supertest. Jest has detected the following 2 open handles potentially keeping Jest from exiting: ● TCPWRAP 22 | 23 | > 24 |…
-1
votes
1 answer

How to store response body in supertest?

I am testing very basic REST api with supertest. I want to save the item id received in response body and assign it to a variable. Using this id i want to make further tests like get-item-by-id or update-item-by-id. No official documentation has…
FishLegs
  • 221
  • 3
  • 15
-1
votes
1 answer

Run supertest e2e with dynamic url for different environments using cli

I have a nestjs backend api server within a monorepo. I want to do integration test using supertest. I have currently configured e2e against jest --env=node --verbose command in package.json. For example, check if http://localhost:8112/health return…
SMJ
  • 716
  • 1
  • 9
  • 23
-1
votes
1 answer

E2E Testing NestJS

Im new to NestJS and im trying to setup my end to end testing. It does not throw any errors but the request always returns 404. The test look like this: import { CreateProductDto } from './../src/products/dto/create-product.dto'; import {…
-1
votes
1 answer

Cannot test delete with supertest (for testing the express app) in Jest

I am testing the logging in and deleting the app account feature of the app. Now the POST and GET methods of login are working fine, but when I run the delete test of the app and check if the database is null, it returns the account details with…
-1
votes
1 answer

How to test Passport.js local auth using jest and supertest

I want to write a test for my passport local auth. If auth is a success or failure in both scenarios the user gets redirected which sends a status 302. Since I can't distinguish between success or failed auth since the status codes are the same, so…
NoobSailboat
  • 109
  • 9
-1
votes
1 answer

Unable to run tests with jest and supertest

I am unable to run the automated tests using jest, supertest and typescript. I am not able to get a simple test to run. All my packages are latest. Please find my package.json, signup test and setup file below package.json { "name": "auth", …
-1
votes
2 answers

Nestjs getting 404 on e2e test but expected 400 (chai & supertest)

Hello Fellow Programmers, i just bumped into a problem that would like to get another eyes into. As im running e2e tests, in this function im getting this error Which seems odd, because when im testing on swagger or postman the request behaves as…
-1
votes
1 answer

how to mock db response in jest?

I wanted to mock the database response from the API request. I am trying to apply Manual Mocks, but it does not work. Every time responds from DB, not from mocks. How can I fixed that? here is my…
-1
votes
1 answer

Supertest: api with "await" was blocked

I use supertest, chai and mocha to run api-testing. I have the following code: app.js app.get('/post', async (req, res, next) => { await postModel.find(); console.log("co xuong duoi la duoc"); res.json({loi: "hi"}).status(200) //…
Linh Ha
  • 65
  • 1
  • 7
-1
votes
1 answer

Attempting to run Jest/Supertest in my nodejs api but keep getting a TypeError : "app.address is not a function"

I'm trying to begin integration/unit testing for my nodejs api but I'm unable to properly connect to my app.js file via supertest. The below code is written in my main.test.js file const app = require('../app') const supertest =…
Light
  • 75
  • 12
-1
votes
2 answers

How to launch supertest files in node?

I have a node/typescript server. I wish to test the api routes with supertest. I've written my first test, but cannot start it because TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for…
DoneDeal0
  • 5,273
  • 13
  • 55
  • 114
-1
votes
1 answer

Node.JS integration test error: listen EADDRINUSE: address already in use :::3000

I've used jest and supertest for integration tests. In afterEach section I closed server: let server; describe('/api/user', () => { beforeEach(() => { server = require('../../../app'); }); afterEach(async () => { await…
-1
votes
1 answer

How to test rest api expecting receive an object?

I'm learning tests and using : Express Jest SuperTest Sequelize This is user.test.js, Everytime I ran the test, it create a user object in database, in app.get("/"),I have a: User.findAll({}); so I would like to test someting more "generic" like…
Hasunohana
  • 565
  • 8
  • 22
-1
votes
1 answer

catch blocks in JEST

I understand how to do a happy path and I have code coverage for all my happy paths, but I'm having trouble figuring out how to handle a catch. I'm currently using supertest So for example I have this API router.get("/all", checkAuth, (req, res) =>…
user6680
  • 79
  • 6
  • 34
  • 78
1 2 3
61
62