luvit
luvit copied to clipboard
luvit/tap - "Missing 1 expected call" not helpful without location of the error
tap's expect() function will produce an error like the following:
[string ".../libs/tap.lua"]:83: Missing 1 expected call
stack traceback:
[C]: in function 'error'
[string ".../libs/tap.lua"]:83: in function <[string ".../libs/tap.lua"]:64>
[C]: in function 'xpcall'
[string ".../libs/tap.lua"]:64: in function 'run'
[string ".../libs/tap.lua"]:163: in function 'tap'
[string ".../tests/run.lua"]:24: in function 'fn'
[string "bundle:deps/require.lua"]:293: in function 'require'
[string "bundle:main.lua"]:118: in function 'main'
[string "bundle:init.lua"]:49: in function <[string "bundle:init.lua"]:47>
[C]: in function 'xpcall'
[string "bundle:init.lua"]:47: in function 'fn'
[string "bundle:deps/require.lua"]:293: in function <[string "bundle:deps/require.lua"]:258>
However, without knowing which function was not called, it is hardly helpful.
Would it be possible to make expect() record the stacktrace when it is called and output that on failure?
That should be possible, good idea.
+1 to this idea, I've suffered writing tests.