expect_json_equivalent function

Test that objects would generate equivalent JSON

Test that objects would generate equivalent JSON

Named lists in R are ordered, but they translate to unordered objects in JSON. This test expectation loosens the equality check of two objects to ignore the order of elements in a named list.

expect_json_equivalent( object, expected, info = NULL, label = "object", expected.label = "expected" )

Arguments

  • object: object to test
  • expected: expected value
  • info: extra information to be included in the message
  • label: character name by which to refer to object in the test result. Because the tools for deparsing object names that 'testthat' uses aren't exported from that package, the default here is just "object".
  • expected.label: character same as label but for expected

Returns

Invisibly, returns object for optionally passing to other expectations.

See Also

testthat::expect_equivalent()