runBlockingTest throws IllegalStateException: This job has not completed yet

runBlockingTest has quite a few pitfalls. One of them is this obscure exception: java.lang.IllegalStateException: This job has not completed yet at kotlinx.coroutines.JobSupport.getCompletionExceptionOrNull(JobSupport.kt:1189) at kotlinx.coroutines.test.TestBuildersKt.runBlockingTest(TestBuilders.kt:53) at kotlinx.coroutines.test.TestBuildersKt.runBlockingTest$default(TestBuilders.kt:45) tl;dr: It is thrown when the test body in runBlockingTest suspends and the dispatcher doesn’t know when it will resume. That can happen if suspend funs are called in the test that have to wait for something from outside the test body. Try to avoid such suspend funs within runBlockingTest.
Read more →

Unit-Test JavaScript of Plain Webpages using Jest

I like to hack little tools together using HTML and plain, old, simple JavaScript. The setup is ridiculously simple, iterations are fast and it runs virtually everywhere. I want to keep those tools as plain and simple as possible without any frameworks like Angular or React. But still I don’t want to miss automated tests. In this post I want to show a simple setup for automated tests for the JavaScript on a plain static webpage using Jest.
Read more →