in auction feature. The project itself was interesting and a little bit tricky, but we could successfully complete it. We have done it using NodeJS with Express framework.
Simultaneously to new features we were adding integration tests for each endpoint, by handling various cases. As a testing framework, we were using mocha.
One of the tricky things was the testing of the “auction ended” event that was emitted after the auction end date was reached. We were needed to create a mechanism that would somehow await the event and based on results pass or fail the test case.
As a solution, we decided to use a modified version of the javascript promise class. We created a new class called "ManualPromise" which looked like this:
And that was it, in the test cases, we were just creating instances of the "ManualPromise" class and resolving or rejecting them whenever it was needed.
Here is the example usage of "ManualPromise" that awaits and handles the “auction end” event :