momentum-mod / website

Momentum Mod's main website.
https://momentum-mod.org
MIT License
55 stars 60 forks source link

Auto mock Angular providers with ng-mocks #871

Closed tsa96 closed 6 months ago

tsa96 commented 7 months ago

We currently have a bunch of stubbed unit tests for various components. I have been very tempted to delete them all for a while now, but they do serve a small purpose: testing that a component can be fully instantiated without firing errors. frontend-e2e actually also does this to an extent, but only for pages/components Cypress actually visits.

Obviously it'd be best to actually unit test everything, but we simply don't have the contributor active to manage that, I'm not willing to put my own time into unit testing frontend stuff when there's so much else I could be working on.

Whilst I can't bring myself to delete the stubbed stuff, it's very annoying when providers change in the component and break tests, sometimes in quite obscure ways (though ditching Nebular will help with that). ng-mocks seems like a sane auto-mocker, so we should switch to that, and the stubbed tests can live on, without further maintenance work. Maybe their existing will encourage more people to write unit tests!

Marking high priority because frontend tests breaking CI is so annoying at the moment.

tsa96 commented 6 months ago

Discussed with Nick and decided remove our stubbed unit tests in the future and close. Doing some manual mocks is not that hard, and we rarely write unit tests on the frontend.