0

I am using React.rb (a opal-ruby binding to react.js) and Opal-rspec for testing.

It seems like I need to reset react's internals between tests as I am getting the awful "Cannot read property ‘firstChild’ of undefined" error, in some tests.

If I move the "failing" test to be the first test, then the error goes away (but can come up in a later test.)

React.rb is NOT being loaded twice, I have made sure a couple of ways including putting a console.log into the first line of the react source file.

SOOO It would seem I need a way to completely clear reacts state between tests. Any way to do that?

ylluminate
  • 12,102
  • 17
  • 78
  • 152
Mitch VanDuyn
  • 2,838
  • 1
  • 22
  • 29

1 Answers1

0

The problem seems to occur if you do a static render of a component that is later asynchronously updated (i.e. when a promise is fulfilled). Once this happens react is busted. I don't know if this is inherent in react, or its because of the reactrb bindings (I doubt that as they are very simple) or something else.

Mitch VanDuyn
  • 2,838
  • 1
  • 22
  • 29