Unless your transactional code relies on deferred constraints. They don’t get checked until commit time so any test that rolls back upon “success” will not reflect an error.
However, I've had success with using the `SET CONSTRAINTS ALL IMMEDIATE`[0] statement prior to rolling back the transaction.
[0]: https://www.postgresql.org/docs/current/sql-set-constraints....