paralleldrive / riteway

Simple, readable, helpful unit tests.
MIT License
1.15k stars 35 forks source link

Intelligible stacktraces on TypeErrors? #299

Closed redbar0n closed 3 years ago

redbar0n commented 3 years ago

Sometimes the stacktraces when using riteway is rather unintelligible, especially when encountering TypeErrors. Example:

not ok 1 TypeError: Cannot read property '0' of undefined
  ---
    operator: fail
    stack: |-
      Error: TypeError: Cannot read property '0' of undefined
          at Test.assert [as _assert] (<app_path>/node_modules/tape/lib/test.js:260:54)
          at Test.bound [as _assert] (<app_path>/node_modules/tape/lib/test.js:84:32)
          at Test.fail (<app_path>/node_modules/tape/lib/test.js:354:10)
          at Test.bound [as fail] (<app_path>/node_modules/tape/lib/test.js:84:32)
          at onError (<app_path>/node_modules/tape/lib/test.js:114:18)
          at processTicksAndRejections (internal/process/task_queues.js:93:5)

Is there a way to get more intelligible stacktraces?

I'd naturally like the testing framework to refer specifically to the line in the test file and the line in the file under test where the error happened.

ericelliott commented 3 years ago

Did you ever find where the error was, and how it was related to your test code? It would help a lot to have more context.

redbar0n commented 3 years ago

Yeah, I resolved it, somehow. But I can't remember exactly how right now. I'll let you know when it happens again, and play around a little to see if I can reproduce it.