Commit 9868381
authored
<!-- What / Why -->
<!-- Describe the request in detail. What it does and why it's being
changed. -->
When testing that a function throws an error, it's easy to forget to
include the `fail` assertion in the try block, and end up with a test
that verifies nothing. I find `throws` and `rejects` assertions to be
less error prone, and try to use them instead of assertions in a catch
block.
Caveat: Unfortunately with tap 16, you can supply an object for
comparison with the thrown error, but can't run arbitrary assertions.
`throws` and `rejects` return the thrown error in newer versions of tap.
## References
<!-- Examples:
Related to #0
Depends on #0
Blocked by #0
Fixes #0
Closes #0
-->
1 parent 36eeeab commit 9868381
1 file changed
+7
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 87 | + | |
| 88 | + | |
93 | 89 | | |
94 | | - | |
95 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
96 | 93 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 94 | + | |
101 | 95 | | |
102 | 96 | | |
103 | | - | |
| 97 | + | |
104 | 98 | | |
105 | 99 | | |
106 | 100 | | |
| |||
0 commit comments