I tried to use custom date strategy in json decoding using Codable
as describe in https://stackoverflow.com/a/28016692/3477974 . Here is the simplified implemen
What you are testing is the date/string conversion so there is no need to involve JSON encoding and decoding into this. Start with a fixed date in string form, convert it to date and back and check the end result vs the fixed date
let input = "2020-02-02T19:10:23.123Z"
let formatter = DateFormatter.iso8601
let date = formatter.date(from: input)
let output = date?.iso8601
print(date != nil && input == output!)
Note that this was written in a playground and not as a unit test