they have flat out said that they plan on expending the first several boosters and starships, there is a reason they are building a factory to mass produce raptors and are already developing revisions to simplify the design to make it cheaper to produce.
Even now, dozens of raptors do not cost hundreds of millions of dollars. They can't be anything close to that expensive given what we know about their production rate. Obviously still a significant cost, and their resources aren't unlimited, but they seem plenty willing to burn some cash to learn some things.
What you say about testing is obviously true and is probably the one outcome that would represent a significant setback to the starship program given the time and money invested in the launch infrastructure. I believe they are confident in avoiding that outcome, or they wouldn't be building all the launch infrastructure ahead of time and so close to the pad. I don't believe spacex has ever had a pad fallback and only the one pad test failure.