You first have to work out if it is fuel or spark.
Thus you get a can of starter fluid & neon tube spark tester, fit it to the mower, remove the hood so you can see it then go mow.
When the mower plays up look at the tester .
no red flashes = replace magneto
Red flashes but no go give it some starter fluid.
Fires right up, = fuel supply problem
Most common fuel supply problems
1) blocked vent in cap
2) debris forming a plug in the tank outlet