How should mutliple render calls in one test behave?
See original GitHub issueI just generated a component integration test for one of my components which has a hardcoded elementId (F*ck me, right?) and the test exploded into my face with
Assertion Failed: Attempted to register a view with an id already in use: myComponentName
because of the two render calls (block and non-block form).
@rwjblue on Slack:
Should we allow multiple
this.render
calls in one test, and if we do should we teardown the prior one before doing another? the answers do not seem obvious to me I guess I would lean towards cleaning up if athis.render
was already run… if you care and have time, i’d love an issue in ember-test-helpers for this it seems somewhat edge-casey but seems valuable to get it right
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
A Complete Guide to Testing React Hooks
This article explores how to test React Hooks and outlines an eight-step testing plan you could employ to test your own projects.
Read more >Testing Recipes
For each test, we usually want to render our React tree to a DOM element that's attached to document . This is important...
Read more >Previous render sometimes leaking into next test · Issue #716
I tried manually calling cleanup() and even unmount() after each unit, but the results are the same. Pasting the relevant code here: App.spec.js ......
Read more >Common mistakes with React Testing Library
The only reason this is useful is to verify that an element is not rendered to the page.
Read more >How to Test React Components: the Complete Guide
Usually done with mounting or rendering a component. example: test if a child component can update context state in a parent. e to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/switchfly/ember-test-helpers/pull/147 added the ability to call
clearRender
as needed, but did not add guards or automatically callclearRender
when multiplethis.render
calls are made.In theory I am fine with either, but kinda lean towards automatically calling
clearRender
on any subsequentthis.render
calls (since multiplethis.render
calls “works” today).I think a second
render
call should properly tear down the first one first. There seems to be no downside to that, and it will Just Work as expected.