In a large stand mixing bowl, combine powdered sugar, egg whites, cocoa, vanilla, and espresso (if using). Mix on low for 1 minute, scrape sides of the bowl. Mix on medium speed for about 5 minutes until light.
On low speed, gradually add the butter in chunks until incorporated. The mixture will appear curdled.
Continue to mix at high speed for about 5 minutes. If it continues to look curdled, take about ¼ cup of the mixture out and heat in the microwave, then add it back into the frosting.
Continue to mix on high until fluffy. Try not to over-mix. If you do so, put the mixture and bowl in the freezer for about 15 minutes, then mix a short time until desired consistency to pipe or spread.