Posts

Showing posts from April, 2020

Test Infinite Scrollers In JavaScript UI

Image
  An infinite scroller is a common JavaScript UI tool which we use to gradually show more records on a page as a user scrolls. It often leaves developers in knots trying to write tests for it because:  it is hard to encapsulate as a simple input/output based  state test it seems the only option is to use e2e testing frameworks because it has  complex interaction In order to test one of these components you just need to properly break apart the callback mechanism inside, then test it via a simple unit test that can control it’s state easily. Now we will look at the  react-window-infinite-loader  which extends the  react-window  control.  Since this article is generic, we are using this NPM module to demonstrate the overall approach to solving this sort of problem (UI controls that have complex state and interaction you want to test). This can be applied in any UI framework. Testing Anything There are usually two approaches to writing tests. Th...