Electrons transmitted across a ballistic semiconductor junction are expected to undergo refraction, analogous to light rays across an optical boundary. In graphene, the linear dispersion and zero-gap band structure admit highly transparent p-n junctions by simple electrostatic gating. Here, we employ transverse magnetic focusing to probe the propagation of carriers across an electrostatically defined graphene junction. We find agreement with the predicted Snell's law for electrons, including the observation of both positive and negative refraction. Resonant transmission across the p-n junction provides a direct measurement of the angle-dependent transmission coefficient. Comparing experimental data with simulations reveals the crucial role played by the effective junction width, providing guidance for future device design. Our results pave the way for realizing electron optics based on graphene p-n junctions.