DNA TEST !?

Has anybody had a DNA test before the baby was born? How did it go & is it safe ?