ApprovalTests failing when files are identical

1.2k Views Asked by At

im using approvals verify in c#

Approvals.Verify(player.ToString());

and it opens in code compare and even when I copy it over it is still failing.

why is it doing this and how can I fix it?

1

There are 1 best solutions below

0
On

This is most likely an issue with encoding of the two files (received vs approved).

Side note: probably 1 is UTF-8 and the other is Ascii. Different diff tools will handle it differently, although in the end approvaltests wants UTF-8 everywhere.

The Best way to solve this is to copy the received file over to the approved file. You can do this manually, but it is easier to use the ClipboardReporter which will automatically add the command line to your clipboard copy/paste buffer

[UseReporter(typeof(ClipboardReporter))]

Then

  1. run the test
  2. open a command prompt (winkey+r, cmd)
  3. paste (right click then select paste, the stand ctrl+c doesn't work here)
  4. hit enter

Happy Testing!