This is only true if they give you a coding assignment after you have interviewed and you actually want the job. Under no circumstances should you waste your time with companies that are just so swamped that you have to jump through hoops so they'll deign to talk to you. Interviews are a two-way street and even an interview for a job I eventually pass on is a two-way street--coding tests aren't, not materially. You learn a little about the company but basically nothing about the people or about the current state of the market (both of the reasons why you should be interviewing even if you're happy with your job--to network with others and to keep your finger on the pulse of the industry).
You probably shouldn't do it if it'll take you more than an hour or so, either, as it communicates how much they respect your time. You can tell if someone can write code in short order. And you would be well-advised not to waste the time of people with ample open-source code you can check out instead. (Shouts, company-that-looked-at-a-completed-CloudFormation-management-stack-and-then-asked-me-to-write-two-for-loops.)
What's actually important is whether you can work with the person, which coding tests don't tell you (and, just as importantly, they don't tell me if I can work with you).