forwardemail / forwardemail/supertest

expect(...) not failing the tests in Jasmine when Error thrown

Open
#732 0 comments 0 reactions 0 assignees View on GitHub
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.

![image](https://user-images.githubusercontent.com/25997477/128788770-ad631123-5473-4a23-b92a-66209fbc5075.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.