question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How should mutliple render calls in one test behave?

See original GitHub issue

I 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 a this.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:closed
  • Created 8 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rwjbluecommented, May 24, 2016

https://github.com/switchfly/ember-test-helpers/pull/147 added the ability to call clearRender as needed, but did not add guards or automatically call clearRender when multiple this.render calls are made.

In theory I am fine with either, but kinda lean towards automatically calling clearRender on any subsequent this.render calls (since multiple this.render calls “works” today).

1reaction
ef4commented, Oct 19, 2015

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found