According to the Endometriosis Association, the only certain way to diagnose endometriosis is via laparoscopic surgery.
(What they don’t say, at least not on that first page, is that even during a lap, a surgeon can either fail to see microscopic endo deposits and/or can miss them if they take samples from the “wrong” place to biopsy.)

Regular surgery can work, too. I knew someone who was diagnosed when they took out an ovarian cyst that the doctor kept insisting was a pregnancy. (“Does this window face east? Is there a star out there? If I’m pregnant, there should be a star in the east,” my friend eventually said to convince him.)
True, though laparoscopy is generally preferred as an intentional means of diagnosis since it’s a smaller surgery. Also, unless the endo was readily apparent (not always the case), it might well be missed if the intent of a surgery was for a different issue.