As far as I know, the Lucas-Lehrer test used by GIMPS does not actually factor: https://en.m.wikipedia.org/wiki/Lucas%E2%80%93Lehmer_primali...
That’s fine for GIMPS, which only searches for Mersenne primes, but doesn’t work in general.
https://en.wikipedia.org/wiki/Primality_test#Fast_determinis... mentions several tests that do not require factorization, though.