oletus
oletus copied to clipboard
Improve stacktrace
Hi!
I have often difficulties to locate which assertion fails in my unit tests. Let's just take an example to illustrate this.
Usually my unit tests have several assertions, such as:
import test from "oletus"
test("example", t => {
t.ok(true)
t.ok(false)
})
The reported location is a bit evasive:
$ oletus test.js
x error
test.js:2
We don't know whether it is the first or the second assertion that failed. It could be nice to get the line where the assertion failed:
$ oletus test.js
x error
test.js:4
However I don't see how to get this location in a reliable way. Indeed: we do not know which assertion library is used and which test pattern are used. The current approach (reporting the test location) seems more reliable.
A possible approach could be to report a reliable location (the location currently reported) and an unreliable location:
$ oletus test.js
x example
test.js:2
test.js:4
However, I am not convinced by this. Have you some thoughts?