'Chai JS flaky test sometimes returning undefined from http call
I am trying to solve a flaky test. It runs fine most of the time locally and then passes about half the times remotely.
The test itself is for an endpoint logic as follows
const chaiHttp = require('chai-http');
const server = require('../my/serveraddress');
[...]
it('Should return 401', async () => {
let result = await chai.request(server)
.post('/my/path');
result.should.have.status(401);
})
Where the handler for that request is:
const getHandlerInfo = async (req, res, next) => {if (!utils.Validate(req)) { return res.status(401).end(); }
someOthercode...
At the moment Validate only returns false, so I'd expect this to pass.
Anyone able to shed some light as to why this only passes some of the times?
I've set the Validate to always return false expecting it might have something to do but it doesn't... I'm a bit out of ideas since logging only gives me the undefined value I was already expecting....
I see a fair bit of posts that get deterministic undefined however that is not my issue...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
