I've had to code something that actually had to do with the job a few times. Like write a basic page that displays X from table Y. Fill in the missing JavaScript function that does Y. Write a SQL query for the report Z. Usually left alone to do it at a computer in the de facto editor for that language.
I've also had written tests with questions to do with the job, not trick questions, just straight, normal, day-to-day problems. Usually 10 or so that start easy and get harder.