Angular component tests

Hi,

Firstly, love the product, and you won me over from LastPass recently with being open source and simple to use.

I am a frontend developer (mostly Angular) in my day job, so I have been looking at the Browser, Web, and Desktop repo’s codebase with keen interest. I noticed that Angular components and services are lacking component/unit tests, so I was wondering if you’d be open for contribution via PR in that area and whether it’d add value to you?

If the answer is yes, my follow-up question would be whether you have any preferences on the testing style. Angular’s out the box testing functionality is great, however in my experience, it can be a pain to set up the fixture, fire events, run change detection and so on. It can also be abit hard to read when the setup is more complex. I’ve been liking the testing approach of https://testing-library.com/ and their angular flavour https://testing-library.com/docs/angular-testing-library/intro. Would be good to hear your thoughts.

Thanks,
William

1 Like

Hi William,

I wouldn’t suspect the dev team, would have anything against more tests.

Regarding frontend test-frameworks, currently jasmine and karma are used in bitwarden/jslib

I’m also in the midst of adding a testbed in the bitwarden/directory-connector, as I would like to make sure I do not break behaviour before fixing a bug. I did have some trouble setting it up though, as I’m more accustomed to the backend(C#, ASP.NET), but would like to further improve my frontend-skills.

Maybe @MGibson could give us some insight/guidance, regarding frameworks and testing styles.

For end-to-end testing, at one of my previous employers we used cypress.io, which was pretty awesome and might be an option.

Obviously with having more tests and thus coverage, it would be neat to report the coverage, maybe as a badge in the README.md. This could be achieved either through an extension of the workflow(Github Action) and committing the badge back to the repo or integrate it with for example coveralls.io

Hi William, welcome to Bitwarden! Thank you for your kind words, post and offer!

Yes perhaps! I think it certainly warrants some discussion. I’m not sure adding unit tests around the Angular UI components is going to gain more or less than our integrated automation/regression test suites will grant us (Our QA team internally has been working through automation of UI test-cases using Selenium, which we use for all clients’ automation). With that, generally the approach of the current unit tests which are there focus purely around reusable logic (e.g. services), especially around areas like cryptography.

As Daniel noted above, we’re currently running tests using jasmine and karma, I believe we would like to stick with the same framework and runner going forward.

As far as “style” goes for tests of Angular components, I believe we’d be open based on the other discussion topics. I’ll open it up a bit more for discussion with @WanderingKazuma & Clayton on test strategy and coverage as well as any other preferences. Thank you for bringing it up!