diagnostic of MacBook

shutdown first

press and hold power button, until boot options screen

press and hold Command+D, until diagnostic screen

tips:

there are prompt texts when holding

connect power adapter ahead, or else, some tests cannot be completed

prepare a pair of headphones

disconnect bluetooth mouse before power on