As it is said (in Genesis 31:4): "And Jacob sent and called Rachel and Leah to the field, to his flock." (And it is written, in 1 Kings 5:10): "And [it surpassed] all the wisdom of Egypt." What was the wisdom of the Egyptians? You find that when Solomon sought to build the Temple, he sent to Pharaoh Necho. He said to him: Send me craftsmen for their wages, for I wish to build the Temple. What did he do? He gathered all his astrologers, [and said to them]: Foresee which men are destined to die in that year. And he sent them to him. When they came before Solomon, he foresaw through the Holy Spirit that they would die in that year. He gave them their shrouds and sent them back to him. He sent word to say to him: Did you have no shrouds to bury your dead? Here, take them, with their shrouds.
Solomon Outwits Pharaoh Necho's Egyptian Astrologers
Midrash Tanchuma Buber, Chukat 11:3
שנאמר וישלח יעקב ויקרא לרחל וללאה השדה אל צאנו (בראשית לא ד). ומכל חכמת מצרים (מ"א ה י). מה היתה חכמתן של מצרים, אתה מוצא כשביקש שלמה לבנות את בית המקדש, שלח אצל פרעה נכה, א"ל שלח לי אומנין בשכרן, שאני רוצה לבנות בהמ"ק, מה עשה, כינס כל (איצטרוגולין) [איצטרולוגין] שלו, [ויאמר להן] צפו בני אדם שעתידין למות באותה שנה, ושלחן לו, כשבאו אצל שלמה, צפה ברוח הקודש שהן מתין באותה שנה, נתן להם את תכריכיהן ושלחן לו, שלח לו לומר לא היו לך תכריכין לקבור את מתיך, הרי לך ותכריכיהן.