A NASA spacecraft has successfully made impact with an asteroid in an unprecedented practice run to thwart potential incoming threats to Earth.