When writing tests, you sometimes need to wait for something to happen. This article describes different methods of doing this, including a new tryUntil() construct available in purple-tape.
Running your code in docker can give you reproducibility and guarantee that your code does not depend on your working environment. Getting it to run just right with tests and a small image size is however fairly complicated. This article explains how to do it with sample code.