This was a moment of truth for Yosef, the moment when he must decide whether he still saw himself as a member of Yaakov's household, or if he has resigned himself to life in Egypt, where he will remain and integrate into society. 

Parashat Vayeshev tells of Yosef's experiences as a slave in Egypt, including the persistent attempts by the wife of his master, Potifar, to seduce him. The Torah tells that one day she grabbed Yosef's garment, at which point "he fled and went outside" (39:12). The Midrash (Bereishit Rabba 87; Tanchuma 9) draws an intriguing association between this instance of the word "va-yanas" ("fled") and its usage in a well known verse in Sefer Tehillim (114:3) describing the splitting of the Yam Suf: "ha-yam ra'a va-yanos" ("the sea saw and fled"). Based on this parallel, the Midrash comments that the sea split for Benei Yisrael in the merit of Yosef, whose remains accompanied Benei Yisrael as they departed from Egypt (see Shemot 13:19), and who, at the age of seventeen, heroically held steadfast to his values and resisted the temptation of his master's wife.

We may understand this association – between Yosef's flight from Potifar's wife and the splitting of the sea – in two ways, corresponding to the two levels at which Yosef is put to the test in this episode. On the simplest level, this is a story of control over one's physical drives, of self-restraint and the fear of God that overpowers all other considerations and natural impulses. Yosef's flight from sin thus resembles the sea's waters' "flight" from its natural course. Just as Yosef acted in opposition to natural tendency, so did the waters of the sea oppose their natural inertia and split to allow Benei Yisrael passage.

Additionally, however, Yosef's test may have involved another dimension. Rashi, in his commentary to this narrative (39:11), cites from the Gemara in Masekhet Sota (36b) that (according to one view) Yosef had at one point agreed to sleep with Potifar's wife until his father's image suddenly appeared. Yaakov warned his son that should he commit this grave violation, his name will be omitted from the kohen gadol's choshen (breastplate), upon which the names of all the tribes of Israel were engraved.

This was a moment of truth for Yosef, the moment when he must decide whether he still saw himself as a member of Yaakov's household, or if he has resigned himself to life in Egypt, where he will remain and integrate into society. His inclusion among the tribes of Israel hinged on his refusal to sleep with his master's wife, which would mark his firm rejection to the immoral and promiscuous culture of Egypt. (See, for example, Vayikra 18:3, where the admonishment to avoid Egyptian practices introduces the section dealing with forbidden sexual relations.)

Several verses earlier, just prior to the story of Potifar's wife's advances, the Torah suddenly tells us that Yosef was physically attractive (39:6). On one level, this information prepares us for the narrative of Potifar's wife. The Midrash, however, cited by Rashi, interprets this verse to mean that as he worked in Potifar's home, Yosef began paying close attention to his looks; his encounter with Potifar's wife served as a punishment of sorts for this preoccupation with external appearance. This perhaps signified Yosef's growing interest and involvement in the culture of vanity that characterized the Egyptian aristocracy, within which he now lived. The test of Potifar's wife thus served to compel Yosef to determine once and for all with which world he identified: the world of his elderly and saintly father, or the world of Egyptian nobility.

If we accept this understanding of Yosef's test, we might arrive at a different approach to the Midrash's association between this incident and the splitting of the sea. Benei Yisrael's crossing of the Yam Suf marked the final break between them and Egypt.

Moshe tells them just prior to the miracle, "the Egyptians whom you see today you will never see again" (Shemot 14:13). It was at this point, after the Egyptian army drowned and the Sea of Reeds returned and stood in between Benei Yisrael and Egypt, that Benei Yisrael could truly proclaim, "Hashem yimlokh le-olam va'ed" ("The Lord will reign forever and ever" – Shemot 15:18), emphatically affirming their exclusive loyalty to God. They have, once and for all, broken from Egyptian culture and paganism, and now make their way to their own homeland, where they will construct a Temple of their own and worship the Almighty.

Indeed, the "Az Yashir" song that they sing after crossing the sea culminates with the verse, "You will bring them and plant them in Your own mountain, the place You made to dwell in, O Lord, the sanctuary, O Lord, which Your hands established" (Shemot 15:17). At this point they have severed ties with Egypt, and begin their march towards their national and spiritual autonomy in the land of their Patriarchs.

It is in the merit of Yosef, who, at his moment of truth, insisted on retaining his identity with Avraham, Yitzchak and Yaakov, and was prepared to forfeit his stature in Egypt on behalf of this identity, that Benei Yisrael earned this miracle of keri'at Yam Suf, which marked their complete separation from the Egyptian culture and lifestyle.