In my experience, I've had Pokemon reach the level that they evolve and faint in battle (in diamond) and they didn't evolve. way back then, I thought of it being a game mechanic; that Pokemon don't evolve when they've fainted, which makes sense, because if they did evolve, their hp would increase and they'd be revived.
Pokémon that get knocked out during a battle will evolve at the end of that battle if its requirements have been met. However, before Generation VI, losing a battle would make Pokémon not evolve even if the conditions have been met.
In Gen 4 and previous generations, this was a game mechanic.