Would NASA point a space telescope at something far enough away in a clean room to confirm that the telescope is functioning correctly before launching it into space? Is there some optical technique that NASA would use?
Mirror testing for any telescope mirror meant to look very far away is probably about the same. They had to get the Hubble mirror to $\lambda /10$ for example and eventually did even though it was already in space!
From the New Scientist's The testing error that led to Hubble mirror fiasco describing the "refractive null corrector":
The reflective null corrector is a cylinder 76 centimetres high and about half a metre wide. It contains two mirrors and a lens, made specifically to test the Hubble primary. By passing light between two mirrors and through a field lens, the instrument should have generated a wavefront matching the desired shape of the primary mirror. The mirror was finished to match the wavefront, so errors in the corrector meant that the final mirror had the wrong shape (see diagram).
But it's not likely the mirrors themselves were damaged, and when stowed they are not even aligned. Once it opens up in space the mirrors have individual actuators that move each element in and out and tilt it under computer control to move them all into a single, shared parabolic surface.
So unless the shock somehow broke, bent, or otherwise damaged one of those elements or its control system, there shouldn't be a big problem getting the JWST to focus as long as there isn't other kinds of system damage.
Now that's certainly a real problem, and I suppose fully assembling the scope in its unfolded position with the secondary in place then trying to point it at a distant object and check the image quality and point spread function is one way to look for that but there are likely some other built-in systems checks.
So checking the optical performance of the complete unfolded and locked telescope is probably not the right test nor the one they would try.
Three kinds of off-axis parabolic hexagons (A, B, C):
From JWST.NASA.gov's Webb's Mirrors