First off, you are not worthless or a failure, even when that annoying voice in your head says you are. The brain is supposed to be the voice of reason, but sometimes we need to take a step back and realize that its logic is often coming from a very flawed place, and we need to guide it into a healthier place.
If you are trying, you are doing amazing. It doesn’t matter if you do fail things, tests, classes, projects, whatever-- trying is doing no matter what the end result is. And I’m massively proud of you for continuing to try even when you’re feeling down and your head is telling you to give up.
You’re a good friend for wanting to support and care for your friend in her time of illness. It can be impossible to just know what a person needs in hard times, so I’d suggest gently asking her how she’s been feeling since the diagnosis, and telling her that no matter what happens, you’re here for her and you’ll do your best if there’s anything you can do to help and support her. Just letting someone know that you are there is already a big show of support and belief. So asking her what she really needs in this time is probably a good idea so you can be as supportive as possible.
I know it’s very hard to deal with feelings of inadequacy. Sometimes it feels impossible. But you are never, never worthless no matter what you fail, no matter what you feel like you’ve failed at. Some regular counseling might be very good if you’re not currently attending any sessions; a counselor can help you sort out why you feel this way, and untangle all the things you’ve been experiencing that leave you feeling so stuck.
I’m proud of you for being brave, seeking help, and wanting to support your friend even when you aren’t feeling as well as you could be.