forwardemail / forwardemail/supertest
expect(...) not failing the tests in Jasmine when Error thrown
- Dominant language
- JavaScript
- Stars
- 14.4k
- Forks
- 782
- PR merge metrics
- No merged PRs in 30d
Description
I am running the Jasmine Test Explorer in VSC with SuperTest 6.1.3.
When I run this test it passes, even though internally it seems to know it should not.
```ts
describe("When throwing an unknown Error from a controller", () => {
it('our router\'s error handling middleware will handle it correctly', function(done) {
// Setup Route
const app = express();
app.get('/example',
(request: Request, response: Response)=>{
throw new Error("Test");
}); // Middleware removed for this error report
// Test
request(app)
.get('/example')
.expect(111) // This
.end(function(res){
done();
});
// The Body will contain verbose amounts of html formatted information.
// If you do not want that, update the error handler.
});
});
```
When I run it from command line using **jasmine-ts**, the test passes but I get an error dump:
```
Started
..Error: Test
at C:\Users\brandito\source\repos\brandonmpetty\Hydra\node-webservice\unittests\lib\expressErrorHandlerMiddlewareTest.ts:37:23
at Layer.handle [as handle_request] (C:\Users\brandito\source\repos\brandonmpetty\Hydra\node-webservice\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\brandito\source\repos\brandonmpetty\Hydra\node-webservice\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\brandito\source\repos\brandonmpetty\Hydra\node-webservice\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\brandito\source\repos\brandonmpetty\Hydra\node-webservice\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\brandito\source\repos\brandonmpetty\Hydra\node-webservice\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\brandito\source\repos\brandonmpetty\Hydra\node-webservice\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\brandito\source\repos\brandonmpetty\Hydra\node-webservice\node_modules\express\lib\router\index.js:275:10)
at expressInit (C:\Users\brandito\source\repos\brandonmpetty\Hydra\node-webservice\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (C:\Users\brandito\source\repos\brandonmpetty\Hydra\node-webservice\node_modules\express\lib\router\layer.js:95:5)
..............
16 specs, 0 failures
```
I expected SuperTest to catch my error and fail the test stating that 111 does not equal the expected 500 status code.

Contributor guide
Assessment
This issue has not been assessed yet.