It is part of a custody arrangement for her seven-year-old daughter, Madison, who she shares with ex-husband Stephen Belafonte.
It comes after the singer, real name Melanie Brown, was accused by a former childminder on Friday of putting her children at risk through her drinking.
Russell Updegraff, who looked after both Madison and Brown’s other daughter, 11-year-old Angel, made his allegation in court papers.
Judge Mark Juhas, sitting at Los Angeles Superior Court, said Brown, 43, would undergo the random testing for four months.
In addition, neither Brown nor Belafonte can take drugs or drink alcohol eight hours before taking custody of Madison, or while they are with her.
A full-scale evaluation of the joint custody arrangement was ordered by Mr Juhas.
Lawyers for Brown and Belafonte declined to comment after the hearing.
Brown was due to appear on America’s Got Talent on Tuesday evening, in which she is a judge alongside Simon Cowell, Heidi Klum and Howie Mandel.
News Source SkyNews