This paper considers testing for unit roots in Gaussian panels with cross-sectional dependence generated by common factors. Within our setup, we can analyze restricted versions of the two prevalent approaches in the literature, that of Moon and Perron (2004, Journal of Econometrics 122, 81–126), who specify a factor model for the innovations, and the PANIC setup proposed in Bai and Ng (2004, Econometrica 72, 1127–1177), who test common factors and idiosyncratic deviations separately for unit roots. We show that both frameworks lead to locally asymptotically normal experiments with the same central sequence and Fisher information. Using Le Cam’s theory of statistical experiments, we obtain the local asymptotic power envelope for unit-root tests. We show that the popular Moon and Perron (2004, Journal of Econometrics 122, 81–126) and Bai and Ng (2010, Econometric Theory 26, 1088–1114) tests only attain the power envelope in case there is no heterogeneity in the long-run variance of the idiosyncratic components. We develop a new test which is asymptotically uniformly most powerful irrespective of possible heterogeneity in the long-run variance of the idiosyncratic components. Monte Carlo simulations corroborate our asymptotic results and document significant gains in finite-sample power if the variances of the idiosyncratic shocks differ substantially among the cross-sectional units.