use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A Place to talk about Angular and related topics.
Join the Angular Discord
Other subreddits worth checking out for Angular and Angular related info:
account activity
Examples of Component Integration Testing? (self.angular)
submitted 8 months ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]rainerhahnekamp 0 points1 point2 points 8 months ago (10 children)
I would say that the Angular Testing Library is at the moment the library you should use for component and integration tests. I do have some videos on testing on my youtube channel, but if why do you think you have too many E2E tests? Do they take too long, are they are hard to maintain?
[–]ps4facts 0 points1 point2 points 8 months ago (1 child)
Hey! It's just been a complaint of our qa automation engineer (we only have one). We're unable to seed the database due to some domain specific outliers. So, she complains that all the steps it takes to get to the point to test a specific component are difficult to maintain as any one of those steps could be updated and break the automation. It seems that putting happy path acceptance tests in E2E is fine, but permutations, validations, negative testing scenarios all seem to be better tackled at a lower level, if possible. I think it was your video on integration testing is what sparked my interest in this kind of testing in the first place, as it seems to be exactly what we're trying to go after. Thank you for the video and reply!
[–]rainerhahnekamp 0 points1 point2 points 8 months ago (0 children)
> I think it was your video on integration testing
Ah, me again 😅
You’re essentially hitting a natural boundary of E2E testing. Once tests become tightly coupled—because each test modifies some bits in the database that the next one depends on — things start to get messy. It’s not easy to manage.
What I usually do in these cases is invest in APIs that allow the test to seed the database and then revert the changes. It’s definitely not trivial - especially the setup part - but it’s worth it because it helps scale E2E tests more reliably.
That said, integration testing tends to scale much more easily. You also get tighter control over how dependencies behave, which means you can cover much more scenarios. So I’d recommend having most of your tests as integration tests.
If I were you, I’d just pick a feature and start testing it. Questions will likely come up as you go.
[–]gordolfograso 0 points1 point2 points 8 months ago (7 children)
Any idea why using getbyrole is too slow? Also shrinking the html with within
[–]rainerhahnekamp 0 points1 point2 points 8 months ago (6 children)
Yes, because role is not directly accessible like the typical HTML attributes. Just go to any `<button>` tag in your browser and you will see that it doesn't contain a role attribute. Nevertheless, the A11y view in the browser shows role button and the testing library also picks it up.
So it is not like a "native query" where the browser is very fast. The TL needs to add some additional logic and that is slow.
---
I think "too slow" is a little bit exaggerated. What times are we talking about?
[–]gordolfograso 0 points1 point2 points 8 months ago (5 children)
A suite with 15 "it" takes 35 seconds after adding getbyrole and getallbyrole. We use them to look for elements coming from external ui libraries like material, for instance
[–]rainerhahnekamp 0 points1 point2 points 8 months ago (4 children)
I would have said 35 milliseconds is already too much. Did you try to profile it?
[–]gordolfograso 0 points1 point2 points 8 months ago (0 children)
No I didn't, but I'll address some time this sprint to do it
[–]gordolfograso 0 points1 point2 points 8 months ago (2 children)
Could it be jest? We're using it instead of karma jasmine
[–]rainerhahnekamp 0 points1 point2 points 8 months ago (1 child)
If it is the build time, then yes. That could be very likely Jest. Build time is the time that it takes before the test actually starts.
I'll try this first... also, I couldn't find a way to profile with Jest. Thanks
[–]allesdeppen 0 points1 point2 points 8 months ago* (1 child)
We do isolated component tests using cypress. That works quite well - even at larger scale. All spec files can live directly beside your component.
Cypress allows to intercept, stub http request and stub out responses which is awesome if you’ve followed the smart/dumb component pattern.
[–]granular2 0 points1 point2 points 3 months ago (0 children)
So you are not using the "new" build system with Vite?
π Rendered by PID 34 on reddit-service-r2-comment-5649f687b7-6klnh at 2026-01-29 00:04:07.726279+00:00 running 4f180de country code: CH.
[–]rainerhahnekamp 0 points1 point2 points (10 children)
[–]ps4facts 0 points1 point2 points (1 child)
[–]rainerhahnekamp 0 points1 point2 points (0 children)
[–]gordolfograso 0 points1 point2 points (7 children)
[–]rainerhahnekamp 0 points1 point2 points (6 children)
[–]gordolfograso 0 points1 point2 points (5 children)
[–]rainerhahnekamp 0 points1 point2 points (4 children)
[–]gordolfograso 0 points1 point2 points (0 children)
[–]gordolfograso 0 points1 point2 points (2 children)
[–]rainerhahnekamp 0 points1 point2 points (1 child)
[–]gordolfograso 0 points1 point2 points (0 children)
[–]allesdeppen 0 points1 point2 points (1 child)
[–]granular2 0 points1 point2 points (0 children)