Is it a known issue that `should` operator does no...
# kotest
k
Is it a known issue that
should
operator does not print stacktrace on a failure? I have a matcher like this:
Copy code
fun beEnabled(buttonModel: ButtonModel) =
  Matcher<ButtonModel> { model ->
    MatcherResult(
      buttonModel.isEnabled,
      { "expected $model to be enabled" },
      { "expected $model to not be enabled" }
    )
  }

fun ButtonModel.shouldBeEnabled(): ButtonModel =
  apply {
    this should beEnabled(this)
  }
On failure
shouldBeEnabled
throws assertion error without full stacktrace which makes it hard to figure out where that assertion failed exactly:
Copy code
java.lang.AssertionError: [REDACTED]
expected ButtonModel(text=Continue, isEnabled=false, isLoading=false, leadingIcon=null, treatment=Primary, size=Footer, testTag=null, onClick=StandardClick(onClick=() -> kotlin.Unit)) to be enabled
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32)
	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32)
	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32)
	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
When I change
shouldBeEnabled
implementation to this, I get the full stacktrace on failure, am I implementing a custom matcher wrong?
Copy code
fun ButtonModel.shouldBeEnabled(): ButtonModel =
  apply {
    this.isEnabled.shouldBeTrue()
  }
r
Perhaps shortened stack trace related to coroutines. I suggest Decoroutinator for restoring stack trace in coroutines.