'Asserting POSTMAN socket hang up
I'm writing a POSTMAN test case where the expected result is a socket hang up: I'm basically trying to authenticate to an API using an invalid client certificate.
Is there any way in POSTMAN to assert on this? In NEWMAN, I'm able to catch the error and compare the error code (ERRCONNRESET) with an environment variable I'm setting through a pre-request script. There seems to be no way to mark this as a test success however.
newman.run({...})
.on('request', function(err, data) {
if (err) {
if (err.code === 'ERRCONNRESET') //test should pass
}
});
Edit: I guess my limited knowledge of NodeJS was at fault here. Adding an eventEmitter and the following line in my if clause solves the issue:
eventEmitter.emit('beforeTest'); //bypass request error, jump to post-request script
The last remaining thing is to set the value of a POSTMAN environment variable from within that if clause.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
