For each test, there are expectations about how good the skater needs to be. The overall quality does not need to be perfect, but at higher levels it should be getting pretty close. At beginning levels, it doesn't even to be very good, but the skater needs to show that they understand the moves and can do them without a lot of mistakes.
The judges use their judgment to decide if the skater has reached the level of quality that they expect for that level of test, or whether they're better than they need to be so they can afford a mistake, or not quite good enough yet.
In the US, tests can pass if there are some very small mistakes, as long as the rest of the skating is good.
If there are one or two medium or big mistakes but the rest of the skating is good, for some kinds of tests the judges might ask the skater to "reskate" that part of the test to see if they can do it without the mistake.
For some kinds of test if there is one big mistake judges can decide to pass the test anyway IF the skating in the rest of the test is really good.
If the skater is just almost sort of good enough for that test, then they can't afford to make any mistakes.