When you go in spectator mode every hostile mob despawns and no other hostile mob ever spawns even when you do /summon command.
Linked issues
duplicates 1
Comments 2
Duplicate of MC-46776 - If you have not, please use the search function in the future, to see if your bug has already been submitted. If you could not find the original report, please comment with the keywords you searched for.
Or rather, this behaviour was specifically introduced as the fix for MC-46776
I can confirm this happens, however if you are the only person in that chunk at that time, then id dare say this works as intended.