Turned 40 and fear of infertility. What test can I do?

Several. See a gyn/infertility specialist who can give you an entire range of assessments to check on your fertility at age 40.
Fertility testing. We check your ovarian reserve (egg supply) with a ultrasound, & hormone tests including amh and a Clomid (clomiphene) challenge test even if your not already trying to conceive. If you are a hysterosalpingogram (hsg) checks your fallopian tubes and uterine cavity, and a semen analysis is done as 40-50% of male partners have a sperm problem. See a fertility specialist (reproductive endocrinologist) for a plan.