Was trying to wrap my head around why the twitter share URL was not working on the test server, as it would say the tweet is too long even though the url should be shortened by Twitter automatically. It seemed I had to use wp_get_shortlink() or a bit.ly link rather than the full URL.
Turns out it was due to the URLs being local.wordpress.dev (the default through VVV, a popular local WordPress vagrant script), and Twitter wouldn’t automatically shorten it.
Not that you should be sharing development URLs anyway, at least now you know it’ll work on a live server. Unless you have a valid top level domain like .black which Twitter won’t shorten, either.