Rework hook error tests to actually assert #1781
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current
hook.err
tests don't actually assert anything, to check that they work you have to uncomment a bunch of lines, and then see if the failing tests are the ones which are supposed to fail.In particular, this makes it difficult to safely implement #1635
I have converted these tests to a new approach which means they do now actually assert things.
I originally began using the
runMocha
helper along with fixtures to do this, but I found that the tests were extremely opaque as they asserted on the details of a complex out-of-band fixture. To combat this I've done something a bit wacky - defined the fixture inline as a function, and then usedtoString
to send that function over the filesystem boundary to generate a fixture on the fly.I think the implementation wackiness is worth the expressive benefit here, but I wanted to get some feedback before I add any more tests for the new functionality described in #1635
As mentioned in the commit message, git isn't smart enough to detect the rewrite of this file, but you can force it to see that the diff doesn't change what is being asserted in any way.