Consider it pure joy, my brothers and sisters, whenever you face trials of many kinds, because you know that the testing of your faith produces perseverance.
James 1:2-3 NIV
The perseverance comes from the desire to continue to work on staying loyal to what you believe in. The trials are meant to serve as a measure of distraction, and also a false sense of failure. Yet, thanks to God's unmoving hand, He will never leave us nor forsake us. However, it's our responsibility to remember His unconditional love when we sin, and walk in His strength to get back up and push pass that desire that doesn't line up with His will for your life. Know that you are valuable, which is why the enemy tries to tempt or test you. However, that's the most crucial time to stay true to God or move closer to Him.