You only perceive the spell did nothing; if there's a save, you think the target succeeded on the save
By the core rules, this is not specified, so the DM must decide how to handle each case.
Xanathar's Guide to Everything however offers the following optional rule (p. 85f) under the heading Invalid Spell Targets:
A spell specifies what a caster can target with it: any type of creature, a creature of a certain type (humanoid or beast, for instance), an object, an area, the caster, or something else. But what happens if a spell targets something that isn't a valid target? For example, someone might cast charm person on a creature believed to be a humanoid, not knowing that the target is in fact a vampire. If this issue comes up, handle it using the following rule.
If you cast a spell on someone or something that can't be affected by the spell, nothing happens to that target, but if you used a spell slot to cast the spell, the slot is still expended. If the spell normally has no effect on a target that succeeds on a saving throw, the invalid target appears to have succeeded on its saving throw, even though it didn't attempt one (giving no hint that the creature is in fact an invalid target). Otherwise, you perceive that the spell did nothing to the target.
As Xanathar's is published later and is often seen as updated rules that close gaps in the core rules, and contains official rules, the closest Rules-As-Written interpretation is that if the spell has a saving throw, the caster thinks itthe save succeeded, and if it doesn't you percieveperceive that the spell did nothing — so if if there is no perceptible effect, you will not even know that. In either case, the spell slot is lost.