Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1751

Making test assertions on variant types

$
0
0

Oh yeah, toEqual works when you’re asserting a specific value expect(res)->toEqual(Success(5))

I think I chose a poor example, but I meant asserting that the res is of type success, without caring what the actual payload is. A better example would be something like a state machine

type multistep =
  | Part1({..})
  | Cancelled
  | Part2({..})
  | Part3({..})

let workflow = Part1({..})
let nextState = applySomeTransition(workflow, data)

expect(nextState)->toBeTypeOf(Part2)

Where I’m just asserting that it transitioned properly, but I don’t care what the actual inner object is


Viewing all articles
Browse latest Browse all 1751

Trending Articles