Tests to detect sleep apnea involve Nocturnal polysomnography. During this test, you are hooked up to equipment that monitors your heart, lung, and brain activity, breathing patterns, arm and leg movements, and blood oxygen (O2) levels while you sleep.