NT tell the difference using a complex combination of clues, including facial expression, body language, tone of voice, context, and the past behavior of the person doing the teasing.
One point is that -- most of the time -- someone that is usually nice to you is not going to just randomly start being mean. Conversely, if someone is usually mean to you, and they tease you, it is unlikely to be friendly teasing. Usually, if the person smiles and looks at your face for more than a second or two, they are being friendly and are hoping to see signs that you find their joke funny.
If someone acts as though you are terrible at something that everyone knows you are good at, this is almost always a friendly, indirect way of giving a compliment.
When you aren't sure, it is good to give the benefit of the doubt. The consequences of error are, in my experience, highly asymmetrical. I think it is better to treat a mean comment like a friendly joke than to treat a friendly joke as if it were a mean comment.
In fact, many socially skilled people deliberately treat mean comments as if they were jokes. When politicians get insulted, for example, they often smile, laugh, and try to say something funny in response even if they know the other person was trying to be mean. It kind of makes sense when you think about it -- if someone is trying to hurt you with a mean comment and you laugh it off as if it were a friendly joke, you've defeated their intent while looking self confident in the process. The only danger here is that some people can't handle getting socially defeated like that and will do something even meaner to try to upset you.