Add onions and spaghetti sauce to ground beef. Add mushrooms, if desired. Bring to simmer. Cook for 30 minutes.
While sauce is simmering, cook spaghetti according to package directions.
Spray a 9x13 inch pan with cooking spray. Make a layer of cooked spaghetti in bottom of pan, add a layer of meat sauce, then a layer of cheese. Repeat.
Bake at 350 degrees for 20 minutes until cheese is melted.
Recipe by A Pinch of Joy at https://www.apinchofjoy.com/2014/06/texas-spaghetti/