Count it all joy, my brothers, when you meet trials of various kinds, for you know that the testing of your faith produces steadfastness.
James 1:2
I think what James is trying to say is that, instead of despising trials, we should make trials our friend.
They will help us grow and mature, just like a good friend would.