When fish is done, it becomes opaque and flakes. To test for doneness, poke the tines of a fork into the thickest portion of the fish at a 45 degree angle. Then gently twist the fork and pull up some of the fish.
Undercooked fish resists flaking and is translucent. If your fish is undercooked, just continue cooking it until it is done.
There’s a delicate balance between perfectly cooked fish and overcooked fish. First of all, remember the principle of residual heat: a pan will hold heat when it’s removed from the heat source, continuing to cook the food for several minutes.
For best results, cook fish until it’s almost done, then remove the pan from the oven, microwave, stovetop or grill and let it stand for a few minutes to finish cooking.
Some fish, especially tuna and salmon, can be served medium rare. I myself do not enjoy fish cooked this way, and serve all of my fish well done, but the choice is up to you.