How does a pre-employment drug test work?

Say a company did pre-employment drug testing. When would they typically do that, and would they give you a warning or a few days notice before doing it? Just wondering if they'd do it at an interview, or if its something more like, they test you once you are given the job or something?
6 answers 6