the answer depends on which model:
Older models that have never had their disk erased, hold the D-for-diagnostics key at startup, and it will be loaded off the original disk. Or insert the original 'shipped in the box' disk 2 of 2 and it will load off there.
If your Mac was introduced before June 2013, it uses Apple Hardware Test
How to use Apple Diagnostics on your Mac - Apple Support
Later MacBooks (after the date above) have Internet Recovery in their ROM, D-for-diagnostics will bring in Internet Recovery, which will download the diagnostic from the Internet (provided your Mac is working well enough to accomplish all that).