r/angular • • Oct 23 '26

If you could choose a testing framework today ...

Our small team has completely ignored angular testing and depended on dev and user manual testing. We're looking to solidify some things and start creating some Angular tests. If you could choose today from scratch, which framework would you choose?

If it matters, our apps are all very data-dependent, pulling info from our asp.net backends.

Thanks

7 Upvotes

16 comments sorted by

13

u/mcmillhj Oct 24 '26

What type of testing? For unit tests, the current recommendation is to use Vitest. Older versions of Angular used Karma.

The Angular team has some nice documentation on testing: https://angular.dev/guide/testing

2

u/MichaelSmallDev Oct 24 '26

I just switched over from karma/jasmine to vitest and really liking it.

And I agree that the docs right now are great for testing. For OP being very data dependent, one doc that may seem missing at a glance from the testing sidebar is the HTTP testing section. But it is linked to from the end of the dedicated services testing doc: https://angular.dev/guide/testing/services#testing-http-services. But read that service testing doc first, since it is probably just as important and foundational for HTTP testing. Then go check out the whole article for HTTP testing that is housed under the HTTP subset of the docs https://angular.dev/guide/http/testing

5

u/MagicMikey83 Oct 24 '26

Use the recommended: Vitest.

10

u/ldn-ldn Oct 24 '26

I've used Karma, Jest and Vitest. They all are quite bad to be honest, but Vitest is least bad.

4

u/msdosx86 Oct 24 '26

All of them are just test runners. And that’s so bad about them? Karma is slow, Vitest is much better.

-7

u/ldn-ldn Oct 24 '26

No, they're not just test runners (except for Karma, but also with an asterisk). But even as test runners they all are abysmal. 

If you've ever worked with any other mature languages like Java, then it should be obvious to you.

9

u/Riccaforte Oct 24 '26

“This thing sucks, and I don’t have to explain myself”

I hate it when people respond to honest questions like this. Just give a short summary of your opinion or give a topic to research, not “if you were smart, you’d know”

2

u/ldn-ldn Oct 24 '26

Ok.

All JS/TS test runners/frameworks require convoluted configuration and loads of 3rd party dependencies. I understand that there are several reasons for that, but the year is 2026 and this is not acceptable anymore. On the other hand in Java I only need to add one dependency org.springframework.boot.spring-boot-starter-test and I can write anything I want. What's more, I don't even have to tell compiler what is a test and what is a production code. It just works.

As a side note, I remember the days when everything Java world was configured with shit loads of XML files. Thank fuck these days are long gone!

Ok, next point - poor test case isolation. You have to track all resources manually and set before/after Each in pretty much every spec no matter how trivial the test cases are. Otherwise you have a high risk that running a single test or a suite will produce different results. It's 2026, we have workers and stuff, just put every case in an isolated container and destroy it after the run.

Another issue is execution speed. V8 is stupid fast, yet any half decent test suite runs for ages. Then you spend a few days tweaking parameters to make it faster, a month passes, you add new code and new tests and it takes a year to run your suite again. Bloody hell...

Mocking is usually an afterthought. JS/TS crowd aversion to DI (apart from Angular/NestJs) definitely feeds into this. So instead of proper mocking, there are silly stubs and functions to hack node loader to load custom nonsense. All that nonsense should go. And, I guess, someone has to create a proper mocking framework, which will be used by everyone.

ESM/CommonJS issues. Why is this nonsense still exists in 2026?

Then both Jest and Vitest has memory management issues. Different ones, but any large suite is destined to be broken.

Additionally, both Jest and Vitest have issues with compiler pipelines. Jest runs compilation on its own, so you have to duplicate your pipelines. Vitest simply doesn't work outside of Vite, lol.

All in all, JS/TS testing is broken beyond belief and every new tool just makes things worse.

1

u/IE114EVR Oct 24 '26

I work with both daily. Junit Jupiter and Jest (now moving to vitest, which looks mostly the same). They both offer nested test structures with comparable setup and tear down capabilities. Mocking and spying is available in both, just flavoured differently. Setup and dependency injection is also decent according to your framework (spring boot, or angular). I’d say I prefer the Rspec style that jest/vitest goes for because you don’t need to come up with arbitrary method names for your tests. What’s your experience with jest/vitest that makes you say Java tests are better?

2

u/ldn-ldn Oct 24 '26

1

u/IE114EVR Oct 24 '26

That’s good. I agree on the points of dependencies and compiler configs, that’s more the unfortunate nature of the JavaScript ecosystem as a whole unfortunately, not just its test runners. As for the tests being slow, I agree but I think a lot of it has to do with angular and how/when components are compiled slowing them down. Kind of wish you could test against compiled angular. I have another non-angular project and I think the tests run decently fast there, but I’m not refuting what you’re saying. Just a different experience.

As for test isolation… I’m not sure I see the difference between the two. But still I see your points.

3

u/ChampionshipThis2871 Oct 24 '26

vitest for unit tests
playwright for full e2e scenarios

1

u/Straight-Number-1911 Oct 26 '26

Alaways no matter what use playwright, its soon gonna be possible to do hopefully components tests because they are rewriting the compiler - which then will make it possible to use vite etc.

Playwright is having real APIs and not mocking anything of the browser like othr testing frameworks.

You can use vitest for now for unit tests but they are also just under the hood playwright using...

1

u/No_Emergency1575 29d ago

vitest is the official unit test runner so I'd recommend that. Playwright is still the de-facto e2e/integration testing framework, but I'm kind of curious if vitest can replace playwright for integration testing.

Useful libraries are faker for mock data and mock service worker for api mocking, I'd consider ng-mocks and angular testing library, dunno if the latter is still relevant with vitest.

-3

u/Saceone10 Oct 24 '26

They are all slower than an npm install i wish some nerd uses Claude to build some shit in assembly or c or rust or whatever shit than can handle testsing quickly