When editing a filter, if a warning message is set, it's possible to get a live preview of it by clicking "preview selected message". The given preview is pretty good, but still different from the actual result. For instance, on itwiki we use a template to build filter warnings, and the MediaWiki page shows a message like "This message is used in filter xxx" below the warning which won't be shown when the warning is triggered. It however appears when previewing the message. There are probably other differences, I think I found another one some time ago but I can't recall it.
Notes: the real message is generated here by just calling $this->msg(...)->parse(), while on the JS-side we do it here using APIs. What we may do is look for a JS method which could produce an output closer to PHP one, although I don't know any.