Skip to content

Conversation

@Agentkma
Copy link
Contributor

@Agentkma Agentkma commented Aug 1, 2019

Please Review

Searched for the ' expect(container.firstChild).toMatchSnapshot() ' in the docs and found 2 examples. Replaced both with ' expect(container).toMatchSnapshot() '

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super! One thought.


// snapshots work great with regular DOM nodes!
expect(container.firstChild).toMatchSnapshot()
expect(container).toMatchSnapshot()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, while we're at it, maybe we should also swap .toMatchSnapshot with .toMatchInlineSnapshot. This will help to encourage people to keep snapshots smaller. This will require that we figure out what the snapshot will really look like so we can inline it. You up for that @Agentkma? If you need help let us know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm up for it. I will look into and let you know if I need help. I've just started learning and using this library, so this is a great opportunity to learn while helping improve things. Win-Win in my book :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so would we want to show a code snippet/or full component of the component(like the Svelt Testing example does?) to show how we find what the string arg to .toMatchInlineSnapshot() ?
Screen Shot 2019-08-01 at 8 18 54 AM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that sounds good. It'll probably need to be something like:

expect(container).toMatchInlineSnapshot(`  <div>  <h1>  Hello  {name}  !  </h1>  </div> `)

I'm not 100% certain that's how it will be serialized, but I'm pretty sure that's what it would look like.

@Agentkma
Copy link
Contributor Author

Agentkma commented Aug 4, 2019

Is this in line with what you are looking for @kentcdodds ? Thanks

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 👍 thanks!

@kentcdodds kentcdodds merged commit c5586e4 into testing-library:master Aug 4, 2019
@kentcdodds
Copy link
Member

@all-contributors please add @Agentkma for docs

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @Agentkma! 🎉

@osinjoku
Copy link

osinjoku commented Aug 5, 2019

Is this how this page is supposed to look? It looks like it interpreted the HTML in the snapshot.
image

@kentcdodds
Copy link
Member

Whoops!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants