Good news: The nonstress test lives up to its name, both for you and baby. It's totally noninvasive, and poses no risk to baby. Be prepared, though—it can easily take up to 40 minutes (make a bathroom stop first!).
The nonstress test evaluates baby's well-being by measuring how her heart rate responds to movement. It's a fetal monitoring method, meaning the purpose is simply to check on baby's well-being, not cure a problem or ensure that baby's born healthy. It's normally performed after 28 weeks, most often in post-term and high-risk pregnancies.
For the test, a Doppler device will be strapped around your belly with a belt. The device is attached to ultrasound transducers, which measure baby's heart rate. At the same time, baby's movements will be recorded, either with another device placed around your abdomen or a button that you press. If baby isn't doing much moving, he's probably snoozing. Your doctor may use a (completely safe!) buzzer-like device to create sound and vibration to wake him, or ask you to eat or drink something to encourage a stir.
What's your doctor looking for? Ideally, baby's heart rate will quicken with movement. If this isn't the case, there could (meaning no need to freak out!) be a problem with baby's health, and your OB may recommend repeating the test or doing another procedure, such as a contraction stress test. If baby doesn't respond after an hour and a half or so, you also may be asked to repeat the test.
Expert source: American College of Obstetrics and Gynecologists. Your pregnancy and birth. 4th ed. Washington, DC: ACOG; 2005.