forwardemail / forwardemail/supertest
Setting cookie with invalid character hangs mocha process
- Dominant language
- JavaScript
- Stars
- 14.4k
- Forks
- 782
- PR merge metrics
- No merged PRs in 30d
Description
I'm having trouble with mocha and supertest. It seems that, when I provide a cookie with an invalid character, my test doesn't exit. The process keeps running.
## Steps to reproduce
Create a new project with `npm init -y` and install dependencies:
```
npm i supertest mocha express
```
Create an `index.js` file with content:s
```
const request = require('supertest');
const express = require('express');
require('mocha');
const app = express();
app.get('/user', function (req, res) {
res.status(200).json({ name: 'john' });
});
describe('app', function() {
it('should exit', function(done) {
request(app)
.get('/user')
.set('Cookie', '‘foo')
.expect('Content-Type', /json/)
.expect('Content-Length', '15')
.expect(200)
.end(function (err, res) {
done(err);
});
});
});
```
Run the test with:
```
./node_modules/.bin/mocha index.js
```
## Expected
An error about an invalid character (`‘` in the cookie) and the process to exit.
## Actual
The error appears but the process doesn't exit.
When I look at the active handles, it seems the server is still running (though I'm no Node internals expert).
## What I've tried
- Return the promise instead of calling `done`
- Adding a `catch` to the end of the chain and calling `done` there
- Wrapping the whole thing in a try-catch
Contributor guide
Assessment
This issue has not been assessed yet.