When testing things I'm for sure are flaky, like d...
# kotest
l
When testing things I'm for sure are flaky, like dynamoDB
a
Do you mean “flaky” as “sometimes it fails, sometimes it passes” or “eventually it passes”?
I’d say the second as DynamoDB is by default eventually consistent. In that case, you can use
eventually
https://github.com/kotest/kotest/blob/master/doc/nondeterministic.md
👍🏻 1
l
the problem with eventually is that I'll have to wrap the whole code in it
And thus every test will have a
eventually(3.seconds) { }
block
a
mmmm Depending on which style you’re using you could create a function that receives a receiver function that “overrides” the style you choose and adds the
eventually
Since I explained myself pretty bad (sorry 😅) probably a snippet is better, something like
Copy code
class MyTests : FunSpec({
    test("overriden") {
        ...
    }
    override fun test(x: String, body: () -> Unit) {
        eventually(3.seconds) { super.test(x, body)
    }
})
I don’t have an open IDE, so it may have some compilation errors
But yeah, having some extension for it will probably simplify things