Questions tagged [chai-http]

102 questions
1
vote
0 answers

Travis is Failing without showing a reason

I am trying to build my project through travis-ci, but unknown error is happening when travis tries to test the project through mocha. i know the issue is not with mysql since the connection is there and scripts are working. I am testing using -…
Moh-682
  • 265
  • 1
  • 3
  • 9
1
vote
0 answers

Running axio request on the server in test environment

I have two different express servers running on localhost on different ports on my laptop. One of them is making a request to the other one. I am trying to test server A using chai-http, but the subsequent request from server A to server B results…
Guillaume Badi
  • 739
  • 5
  • 13
1
vote
1 answer

Resolving promises with chai-http respons

I am very new to NodeJs and trying to run tests. I am trying to return http response from a get call so that I can run assertions on it. SendGetResponse() returns promise and sendResponse awaits this promise to be fulfilled. But I get (node:2152)…
1
vote
1 answer

NodeJS - Can't attach Client Certificate for Testing with Mocha/Chai-Http

I'm checking the client certificate on my login endpoint. Testing with Postman etc. all works just fine, but I can't get it running with my mocha/chai-http unit tests. const ca = fs.readFileSync(path.join(__dirname, '..',…
phoebus
  • 1,016
  • 10
  • 25
1
vote
2 answers

UnhandledPromiseRejectionWarning on test failure

I have some mocha/chai/chai-http tests that follow the below structure however whenever one test fails I get an UnhandledPromiseRejectionWarning which I can't seem to figure out it's source. UnhandledPromiseRejectionWarning: Unhandled promise…
ninesalt
  • 2,968
  • 3
  • 23
  • 49
1
vote
1 answer

chai-http treats two different fields with the same name as if as one field

I use mocha and chai-http to test my api server . The problem is that it treats the query {stock: 'msft', stock: 'aapl'} as if it is { stock: 'aapl' }. Test : var chaiHttp = require('chai-http'); var chai = require('chai'); var assert =…
isemaj
  • 357
  • 1
  • 4
  • 13
1
vote
1 answer

UnhandledPromiseRejectionWarning during testing with mocha-chai using chai-http

Making my first express app, I am trying to write a test for an api endpoint and using data structure as place-holder for a database but keep getting an error in the console as shown in the pic even though the test 'passes' import chai from…
1
vote
0 answers

chai-http - res.json is not a function when called from unit test

I have a node app which exposes a simple REST api using express. It includes a GET endpoint which should return a JSON array of data from a mongo database. It works perfectly when tested from Postman. api.get('/queries', (req, res) => { …
barry
  • 3,741
  • 4
  • 36
  • 65
1
vote
1 answer

async functions not executed in server when testing with chai-http

I have the following function in my app.js let memoryCache = require('./lib/memoryCache'); memoryCache.init().then(() => { console.log("Configuration loaded on app start", JSON.stringify(memoryCache.getCache())); }); app.use('/v1',…
suku
  • 8,833
  • 13
  • 57
  • 108
1
vote
1 answer

Ping an express + sequelize server with chai-http

I'm having issue on setting up tests with Express and Sequelize. I'm using Mocha + Chai for tests. I'm just trying to ping for now. Code of server.js : const express = require('express'); const Sequelize = require('sequelize'); const bodyParser =…
pierreaurelemartin
  • 1,142
  • 1
  • 10
  • 22
1
vote
0 answers

Cannot import declaration file

I'm trying to set up some test for my RESTAPI server. I use typescript. I tried to import chai and chai-http using the ES6 syntax, but apparently, it's not supported (Github issue here ). I get an error, so I had to require the files directly. var…
Loic Coenen
  • 555
  • 2
  • 5
  • 17
1
vote
0 answers

Uncaught AssertionError: expected { Object (address, street, ...) } to deeply equal { Object (address, street, ...) } + expected - actual

This is Object i am posting in server let targetTestObjectToPost = { name : { name : "something", middle : "something", last : "something" }, date_of_birth :…
freakZ
  • 56
  • 5
1
vote
1 answer

Chai http Promise never failing

I am using Chai http and the promise. The following test should fail, but it passes without ever calling the then function. If I add the done parameter to wait for the async function to finish, it fails (correctly). Am I doing something…
El Mac
  • 2,782
  • 5
  • 27
  • 48
1
vote
0 answers

chai expect stops execution instead of failing

My problem workaround should be a very basic one. I am using mocha, chai and chaihttp to test my API set import app from '../index' import chai, {expect} from 'chai' import chaiHttp from 'chai-http' chai.use(chaiHttp) describe('----- cloud…
Faysal Ahmed
  • 1,494
  • 13
  • 23
1
vote
0 answers

Testing multiple simultaneous sessions with mocha-chai superagent

I am trying to write tests for multiple socket connections, which I need to have multiple sessions (simultaneously) for since they are identified by session ID on the server side... In the example below client1 will connect and the handshake will…
Koborl
  • 235
  • 1
  • 10