Order Of Functions Being Executed In Express Messed With Tests
I was trying to integrate Jest and Supertest to build integration tests on some middleware. I generated my middleware functions dynamically as they varied route to route, and the l
Solution 1:
It turns out this is because Express executes the middleware generating function at app creation time It's the resulting function that's continuously called throughout the app. The generating function is called once, its result is called many times.
You have to mock the function that your middleware generating function produces, (i.e. the result of middleware1
), not the generating function itself.
Post a Comment for "Order Of Functions Being Executed In Express Messed With Tests"