I have a player in my campaign who took the Flames of Phlegethos tiefling racial feat (from Xanathar's Guide to Everything, p. 74-75). One of its benefits is:
Whenever you cast a spell that deals fire damage, you can cause flames
to wreathe you until the end of your next turn. The flames don’t harm
you or your possessions, and they shed bright light out to 30 feet and
dim light for an additional 30 feet. While the flames are present, any
creature within 5 feet of you that hits you with a melee attack takes
1d4 fire damage.
Additionally, he took the produce flame cantrip:
A flickering flame appears in your hand. The flame remains there for
the duration […]
You can also attack with the flame. When you cast this spell, or as an
action on a later turn, you can hurl the flame at a creature within 30
feet of you. Make a ranged spell attack. On a hit, the target takes 1d8
If he casts the produce flame cantrip and holds it (i.e. doesn't attack or attempt to deal damage with it), would that still trigger this benefit of the Flames of Phlegethos feat?
He's cast a spell. Check.
That spell deals fire damage. Check.
Now, he doesn't get the effect if/when he throws it on a later round, but it totally counts for the round he cast it.
If it had said "when you cast a spell and it deals fire damage" that would be a different story, as that would require that fire damage had actually been dealt. (It also wouldn't work if you threw a fire bolt and missed, or in some other way failed to successfully deal your damage.) In this case, though, it's checking for "deals fire damage" as a feature of the spell that you cast.