James writes this is 1:2 Consider it all joy, my brethren, when you encounter various trials, 3 knowing that the testing of your faith produces endurance. 4 And let endurance have its perfect result, so that you may be perfect and complete, lacking in nothing.

The reason someone can consider a trial as all joy is because when you see God’s grace sustain you in a difficult trial, you then have that much more settled confidence that you can make it through anything in a way that glorifies God. Think about it this way—No one marvels at the sustaining power of God’s grace when everything is going well. But when he remarkably and unexpectedly works in serious suffering through granting a sustained and even strengthened faith, there’s nothing more encouraging and compelling to the Christian than that. That’s why James teaches this work of God makes one fully mature and complete.