supertest test express middleware

后端 未结 1 1808
轮回少年
轮回少年 2021-01-18 08:21

found the following hint on how to test middleware in express:
https://github.com/visionmedia/express/blob/master/test/req.xhr.js
I was wondering why my tests were al

1条回答
  •  爱一瞬间的悲伤
    2021-01-18 08:45

    You didn't miss anything, it is the express test req.xhr that will never fail.

    If running your example, you will see the error stacktrace but the test passes because:

    1. it didn't catch the error during test.
    2. no error information passed to done() function call.

    My fixes are in PR #2053:

    1. use expect() to return the assertion error to .end().
    2. pass any error information to done().

    0 讨论(0)
提交回复
热议问题