Every state has different regulation and it may vary from hospital to hospital. It can also depend on your OB/midwife. What they tell you can very much depend on you, if you got regular and early prenatal care, very cooperative and followed all their instructions; if you present yourself as a caring and cared for mother to be, then there may not be any reason for them to test you. However if you or those around you send out warning signals with their presentation, dress or behavior, your health provider can very well test your baby's meconium (poop) without your consent. They can not test you without your express consent and knowledge.
You should be aware that your baby's meconium will show every drug you have used from the 20th week of pregnancy.
Please read my blog on pregnancy and addiction by clicking on my name in blue and than "blogs". Good luck to you.