Pregnant women can also prevent spreading the infection to their babies by getting tested for group B strep late in pregnancy. The test is often done 35 to 37 weeks into the pregnancy. Antibiotics are given during labor if the test is positive. This can prevent the spread of the bacteria to the baby.