The answer depends on the jurisdiction you are in and the final requirements of the Judge. In many counties the Judge will appoint a guardian ad litem (an attorney appointed to represent the best interest of the child) for the unborn child. After an investigation, the guardian ad litem will make a recommendation to the court relative to the parentage of the child. In some cases there may need to be paternity tests before the final divorce.
Check with the Clerk of Courts office in your county to determine the specific requirements