Closed stdedos closed 4 months ago
Hey :wave: , thanks for reporting this issue. Will try and have a look at it asap.
Indeed I can reproduce the issue, and looking into it probably never worked correct. Not sure how I missed that. Will issue a pr later today fixing this. Again thank you for reporting this with clear steps on how to reproduce and the fix.
Description
For code https://github.com/stdedos/junit2html/blob/927e5218bb0ff447cd5390a7190a34db5a1b4b9a/tests/file_based_test.go#L94-L97, it seems that
go-snaps
will print the wrong snapshot path:(forget about the failing test)
The
at ../
path is clearly wrong - as theand the
path have the same parent folder.The issue is at https://github.com/gkampitakis/go-snaps/blob/c578aa766e5e2c543de3b6c73586e840e90aeee8/snaps/snapshot.go#L256-L274, and specifically in
snapPathRel, _ := filepath.Rel(callerPath, snapPath)
.callerPath
is used "interchangeably" as a filename and a directory. It seems that insnapPathRel, _ := filepath.Rel(callerPath, snapPath)
it was forgotten that it is a filename.Apart from the necessary
filepath.Dir(callerPath)
, I'd also suggest renaming this tocallerFilename
, highlighting its correct contentsSteps to Reproduce
Run https://github.com/stdedos/junit2html/blob/927e5218bb0ff447cd5390a7190a34db5a1b4b9a/tests/file_based_test.go test
Expected Behavior
No response