Skip to content

Added example for container #114

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

Merged
merged 2 commits into from
May 20, 2019
Merged

Conversation

ematipico
Copy link
Contributor

@ematipico ematipico commented May 18, 2019

This should be merged after testing-library/svelte-testing-library#24 will be published

cc @benmonro

This should be merged after testing-library/svelte-testing-library#24 will be published
@@ -58,13 +58,14 @@ describe('App', () => {
})

test('should change button text after click', async () => {
const { getByText } = render(App, { props: { name: 'world' } })
const { getByText, container } = render(App, { props: { name: 'world' } })
Copy link
Member

Choose a reason for hiding this comment

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

@ematipico actually would you mind adding this in a separate section? for this basic example, I'd prefer to keep it as is, and then have 'containers' be listed below.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const { getByText, container } = render(App, { props: { name: 'world' } })
const { getByText } = render(App, { props: { name: 'world' } })


fireEvent.click(getByText('Button Text'))

const button = await waitForElement(() => getByText('Button Clicked'))

expect(button).toBeInTheDocument()
expect(container.firstChild).toMatchSnapshot()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
expect(container.firstChild).toMatchSnapshot()

@benmonro benmonro merged commit f8d46a4 into testing-library:master May 20, 2019
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

Successfully merging this pull request may close these issues.

2 participants