Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How would addSnapshotSerializer fit in bs-jest? #68

Open
davesnx opened this issue Apr 19, 2020 · 1 comment
Open

How would addSnapshotSerializer fit in bs-jest? #68

davesnx opened this issue Apr 19, 2020 · 1 comment

Comments

@davesnx
Copy link

davesnx commented Apr 19, 2020

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!

@glennsl
Copy link
Owner

glennsl commented Apr 23, 2020

Hey. Sorry for the late response. It's a bit of a chore just to get into this as I don't even use bs-jest regularly these days.

I think you could just implement this as a standalone binding though. Noe need to involve any of the existing stuff. Just put an ordinary external in the Expect module, and that's that. Or am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants