In MUnit you can also check this using compileErrors:
assertNoDiff(
compileErrors("Set(2, 1).sorted"),
"""|error: value sorted is not a member of scala.collection.immutable.Set[Int]
|Set(2, 1).sorted
| ^
|""".stripMargin
)