Well that was certainly the case with whiteboard interviewing; it's a terrible way to evaluate a potential hire.
https://medium.com/p/its-time-to-retire-the-whiteboard-interview-6b41797332c5
But someone (probably Microsoft) started interviewing this way and everyone copied them.
Many, many, many times I have taken a job using a framework or even a programming language that I didn't know, which I learned along with the existing codebase. In the last three years I have learned or relearned C#. ASP.NET, JavaScript, Python, and Django, along with several cryptography libraries and carf-scanner embedded systems. I would have failed a test in any of them yet I ended up in all cases taking on central responsibility for my projects and producing huge amounts of nearly or completely bug-free code.
When I interviewed people I would just talk to them. We'd discuss approaches to problem-solving; if the interviewee said that however the team did design, formatting, whatever was how he would do it, he got a thumbs down, even if he was, no, especially if he was knowledgeable and experienced. On the other hand a candidate who has a lot less experience but thinks about design, who doesn't simply obey compulsions like optimization, he has potential and gets a thumbs up.
A test would give opposite results.