I mean in-game, not on competitive things like Showdown or the Battle Subway.
From personal experience I know it counts as a loss. You black out and return to the Pokemon Center as you have no Pokemon left.