Here is a failing spec:
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
module README where
import Test.Hspec
import qualified Test.Hspec.PrettyJSON as PrettyJSON
import Data.Aeson
import GHC.Generics
data Person = Person {
name :: String
, age :: Int
} deriving (Eq, Show, Generic, ToJSON)
person :: Person
person = Person "Joe" 23
spec :: Spec
spec = do
describe "PrettyJSON" $ do
context "when comparing aeson Values" $ do
it "pretty-prints JSON values" $ do
toJSON person `shouldBe` toJSON person { age = 42 }
context "when comparing Strings" $ do
it "pretty-prints JSON values" $ do
encode person `shouldBe` encode person { age = 42 }When you run this spec with
main :: IO ()
main = hspec specyou will get output of the form:
By using PrettyJSON
main :: IO ()
main = hspec $ PrettyJSON.use specthe JSON values will be pretty-printed:

