Gary Oliver, Sam Nicholson, Jordan McGhee and Juanma Delgado were on target for the Jambos, while James English scored twice for the hosts.
Defender Alim Ozturk was substituted 26 minutes into his first pre-season game following a minor stomach operation but the club revealed the move was only a precaution because of a tight thigh.
Hearts went ahead shortly after Ozturk departed when the home defence failed to clear a long ball forward and Oliver fired home from the edge of the area.
Robbie Neilson sent out an entirely different Hearts XI for the second half and a mix-up in the visitors’ defence allowed English to level for Shelbourne.
Hearts were quickly back in front after more defensive confusion allowed Nicholson to pounce and the Scottish side then took command with their third goal arriving 10 minutes from time when McGhee curled home a superb free-kick from the edge of the box.
English replied immediately with a looping header when he was left unmarked but Hearts secured the win at the death when new signing Junama side-footed home Osman Sow’s centre.