Fix issue that clearRecordedEvents is not triggered