In situ nanomechanical testing in (scanning) transmission electron microscopy provides unique opportunities for studying fundamental deformation processes in materials. New insights have been gained by combining advanced imaging techniques with novel preparation methods and controlled loading scenarios. For instance, by applying in situ high-resolution imaging during tensile deformation of metallic nanostructures, the interplay of dislocation slip and surface diffusion has been identified as the key enabler of superplasticity. Evidence for dislocation pinning by hydrogen defect complexes has been provided by in situ imaging under cyclic pillar compression in a tunable gas environment. And, for the very first time, individual dislocations have been moved around in situ in two-dimensional materials by combining micromanipulation and imaging in a scanning electron microscope.