وَلَقَدْ فَتَنَّا ٱلَّذِينَ مِن قَبْلِهِمْ ۖ فَلَيَعْلَمَنَّ ٱللَّهُ ٱلَّذِينَ صَدَقُوا۟ وَلَيَعْلَمَنَّ ٱلْكَـٰذِبِينَ Qur’an Al-Ankabut (29:3)Walaqad fatanna allatheena min qablihim falayaAAlamanna Allahu allatheena sadaqoo walayaAAlamanna alkathibeena
I.e., to others and/or to themselves (see note [7]).
The word "know" is used here more in the sense of testing than of acquiring knowledge. Allah is All-Knowing: He needs no test to increase His own knowledge, but the test is to burn out the dross within ourselves, as explained in the last note.