-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite using unexpected-mitm mocker #7
Rewrite using unexpected-mitm mocker #7
Conversation
Make the promise factory mode run via the mocker.
Include a suffix in the test file name allowing the output to be run by jest on the command line. Also add the runner to the name.
When encountering an early exit situation the mocker will resolve. This would previously cause the assertion to immediately kick in While the it() block may not yet have completed at. Defer executing the assertion until both mocker & afterEach promises are complete.
2 similar comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pure win! 🚢
lib/httpception.js
Outdated
resolvePromise, | ||
mockerPromise | ||
]).then((result) => { | ||
return expect(function afterEach() {}, 'to perform HTTP traffic', mocker.descriptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit weird with the empty function? It suggests that the assertion should be shuffled around a bit so it can be something like expect(mocker, 'to have performed the HTTP traffic that it was supposed to')
? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh yeah - the reason it looks this way is actually to trick Unexpected into inspecting it (so you get a hint it was in afterEach) but then to output the same assertion as in the promise factory case - having httpception
output two different assertions felt like an output inconsistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only other way I could think of doing it was to get really deep into overriding the error message and I wanted to avoid that as part of this cleanup..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair :)
No description provided.