Very curious about this because there are electric planes in testing, so how do they do it?
The existing electric planes are designed to be trainers. They are primarily for takeoff and landing and flying in the pattern at an airport. Less than 1-hour endurance, and useful load that can barely accommodate two people.
They are designed for drastically shorter flight times. Of the airframes I am aware of that are actually flying right now (pipistrel and the beaver) both of them have a range of approximately 1/5 that of the same airframe with a gas engine.
The Pipistrel is probably the best example since it is actually available for sale in both ICE and electric. The ICE version of the airframe has 5.5 hours of cruise fuel good for 650 NM. The electric version has a payload that is 60% less, a ceiling of 12k feet compared to 18k feet, and an endurance of 56 minutes.
Basically, they are sacrificing range and payload. It isn't that electric planes can't possibly fly, its that ICE powered planes have a pretty hard to overcome advantage until battery power density increases by an order of magnitude. There are already mass market brushless motors that could replace most aircraft engines at a lower weight.
The problem is that gasoline holds 30x or more energy than a battery by weight. It doesn't matter if I can get replace 100 lbs of ICE engine with 1 lb of electric engine, because the real issue is that I would need a literal ton of batteries to replace less than 100 lbs of gas.