Let me start by saying that the most important thing is that you provide honest and truthful testimony, regardless of whether you are paid or not.
Expert witnesses are routinely compensated for their time in preparing expert reports and testifying.
However, if you are not testifying as an expert witness, but instead serve as a fact witness---i.e., a witness to the events at issue in the law suit, it would be unusual for you to receive compensation. In fact, in some jurisdiction it is illegal and/or unethnical for fact witnesses to receive compensation. If you live within the same city or county of the Court in which the case is being heard, you ordinarily can be compelled to testify via subpoena, and you generally would not be entitled to compensation (there are exceptions to this in certain situations and types of cases). If you live outside the scope of the Court's subpoena power so that you could not be forced to appear, and you nevertheless voluntarily agree to testify, it is possible that the lawyers who ask you to appear will offer to pay for your time and expenses (or at least your expenses). You would have to disclose that you are receiving these payments, and your credibility probably would be challenged on cross-examination if you receive payment from the party who you help in your testimony.
In some situations, the line between an "expert" witness and a "fact" witness is unclear. For example, a physician who treated an accident victim (or the victim of a criminal assault) might be deemed to be both a fact and expert witness, in which event in most jurisdictions it would be appropriate for the witness to receive compensation for his/her time. Whenever a witnesss testifies at least in part as an expert, compensation is usually deemed appropriate.
But the situation is quite different for fact witnesses. Even in those jurisdictions in which it is legal and ethical to compensate fact witnesses for their time, such compensation is usually frowned upon. Lawyers are very wary about providing compensation to "fact" witnesses who are not serving as experts because there may be a "smell factor" associated with such payments that undermine the credibility of the lawyer and his client. And of course, it is illegal--and indeed a serious criminal offense---to pay someone to testify falsely.
Often, the lawyer for one party or the other will offer to "prepare you" to provide testimony, but you may not enjoy the protection of the attorney-client privilege if this lawyer has not agreed to represent you personally. You should not assume that your friend's lawyer is acting in your best interests, nor should you assume that you have an attorney-client relationship with your friend's lawyer. Unless you have a written retainer agreement with the attorney for your friend (or at least a letter confirming the existence of an attorney-client relationship), you should assume that such attorney is not acting for you, and that such attorney has no obligation to protect the confidentiality of information that you disclose to her, including informatoin about compensation arrangements the attorney may have made with you.
Finally, whenever a witnesses such as you offers to help a friend by providing testimony, it is a good idea for you to consult your personal lawyer so that your personal interests are protected. Court proceedings are serious matters, and if you are asked to provide testimony to support a friend's position in a law suit, it is a good idea to obtain assistance from your personal lawyer in preparing to testify, and to have your personal lawyer represent you in court. And if you are offered compensation for your testimony, you should check with a lawyer to make sure that it is legal and ethical for you to accept that compensation. It often is not.