Skip to content
Playground(another site)

bynk.observe.impure_with

Error A with predicate uses an effectful or test-only construct, or an effectful call (a sub-expression of type Effect[_]); it must be pure.

The with predicate of expect Cap.op called with … is tested against every recorded call, so it must be a pure expression of the operation's arguments. trace(…), a capability call or anything else effectful or test-only could give a different answer each time. Compare the arguments, or bind trace(Cap.op) first and assert on the list.

Example

tests/t.test.bynk
expect Logger.log called with trace(Logger.log).length() > 0 // ✗ not a pure predicate
expect Logger.log called with msg == "x" // ✓

In the Book

See also

  • Every code in its category, Observation, on the diagnostic index.
  • bynk explain bynk.observe.impure_with shows the same from the installed toolchain, without a network.