Skip to content

How would addSnapshotSerializer fit in bs-jest? #68

@davesnx

Description

@davesnx

Hey @glennsl

I was trying to add the "binding" to expect.addSnapshotSerializer() in bs-jest and I found creating too much crap for this particular case.

How it works it's simple, while expect.extend adds prototype methods to the matches, expect.addSnapshotSerializer adds transformations to the snapshots and both methods are called once on top of the file (or in any setup.js file)

That's a valid serializer:

const serializer = {
	test: () => true
	print: (value) => JSON.stringify(value)
}

expect.addSnapshotSerializer(serializer);

So, a serializer it's a

type serializer = <
  test :value -> bool;
  print :value -> serialize -> indent -> string
> Js.t

But I end up adding addSnapshotSerializer to the prototype with the affirm. Would you mind some advice on how to add it without too much hassle?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions