What happens if a wizard uses a spell against a monster that is immune to it?
It is treated the same as if they rolled a number that was too low.  They are defeated and suffer the usual consequences.

There are various different versions of the rules.  The ones here show it on page 10, third paragraph.