Marble testing

Testing asynchronous code can be challenging. For one, we have the time factor. The way we specify what operators to use for our crafted algorithm leads to the algorithm taking anywhere from 2 seconds to 30 minutes to execute. Therefore, it will at first feel like there is no point in testing it, because it can't be done within a reasonable time. We have a way to test RxJS, though; it is called Marble testing and it allows us to control how fast time passes so we have a test that can execute it in milliseconds.

The idea of a Marble is known to us. We can represent one or many streams and the effect an operator has one two or more streams. We do this by drawing the streams as a line and values as circles on the lines. The operator is shown as verb below the input streams. Following operator is a third stream, the result of taking the input streams and applying the operator, a so - called marble diagram. The line represents a continuous timeline. We take this concept and bring it to testing. What this means is that we can express our incoming values as a graphical representation and apply our algorithm to it and assert on the result.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.106.96