For Apple silicon Macs... Press and hold the power button on your Mac. Continue to hold the power button until you see startup options. Press and hold Command D on your keyboard.
Intel Macs... Turn on your Mac and then immediately press and hold the D key. Release when you see a progress bar or language choose appears.
Note 1: If D key doesn't work, try Option D at startup instead. Note 2: You may be asked to choose a language. Note 3: You need a network connection. You can use the Wi-Fi menu.
You should see a progress bar while the test proceeds. When complete, diagnostics shows the results with reference codes.
See the tips entry "Apple Diagnostics Codes" in this database for details.
To restart your Mac, click Restart or press R. To shut down, click Shut Down or press S.