1 "If a prophet or a dreamer of dreams arises among you and gives you a sign or a wonder,
2 and the sign or wonder that he tells you comes to pass, and if he says, 'Let us go after other gods,' which you have not known, 'and let us serve them,'
3 you shall not listen to the words of that prophet or that dreamer of dreams. For the LORD your God is testing you, to know whether you love the LORD your God with all your heart and with all your soul.
It may seem strange to us that God would allow a person the power of prophecy when they would use it to draw people away. This is even more strange when we remember that God uses signs and wonders to authenticate the prophet and the words that he speaks through the man. However, it is never signs alone which we are to look for. The message preached is essential to get right.
This situation is a reminder to us to know the bible well enough that we can tell when the signs are false. The New Testament even speaks of false signs which will be used to draw people away from the truth. How do we tell when the signs are false? When the 'prophet' or miracle worker contradicts God and God's revealed word in the bible.
More specifically, when the 'prophet' acts and teaches in a way that works against the fruit of the Spirit (love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, self-control), or which draws people away from God, then you know they are not of God - no matter what amazing things they may do.