Frontend Frameworks · QA Testing
React vs Angular for QA Testers: A Practical Comparison
A test passes on your machine, fails in CI, and passes again when rerun. In a modern single-page app, the cause is very often one of two things: a locator tied to something the framework generates, or a check that runs before the framework has finished updating the page. React and Angular cause these problems in slightly different ways. Once you know them, you can write tests that survive both.
How each framework updates the page
Both React and Angular render ordinary HTML in the browser; your test tool sees a normal DOM in both cases. The difference is how they decide what to change.
- React re-runs component functions when state changes and compares the result with the previous output (the "virtual DOM"), then updates the real DOM. Elements can be replaced rather than modified, so a reference you grabbed earlier may point to a node that is gone.
- Angular uses templates and change detection: after events, timers or HTTP responses, it checks bindings and updates the DOM. Recent versions also offer signals and zoneless change detection, but the effect for a tester is similar: the DOM updates shortly after the triggering event, not instantly.
In both cases, the rule is the same: never assume the page is ready right after an action. Assert on the state you expect and let the tool wait.
Locators: what to avoid in each
| React apps | Angular apps | |
|---|---|---|
| Generated attributes | Hashed class names from CSS-in-JS or CSS modules (for example sc-1x2y3z or Button_primary__a1B2c) change between builds | _ngcontent-… and _nghost-… attributes from view encapsulation; ng-reflect-* attributes, which appear only in development builds |
| Elements outside the component | Modals and tooltips rendered through portals, usually at the end of body | Angular Material and CDK overlays (selects, dialogs, menus) rendered in a separate overlay container |
| Lists | Rows re-created when the list re-renders | Rows re-created by *ngFor / @for when data changes |
| Common test hooks | data-testid (popular because React Testing Library supports it) | data-testid, data-cy or stable custom attributes agreed with developers |
Long CSS or XPath chains such as div > div:nth-child(3) > span are fragile in both, because small template changes break them.
Locators that work in both
Playwright's recommended locators are based on what the user sees: roles, accessible names, labels and text. They do not depend on the framework at all:
import { test, expect } from '@playwright/test';
test('user can submit the enquiry form', async ({ page }) => {
// Make the course list deterministic instead of depending on a live API
await page.route('**/api/courses', route =>
route.fulfill({ json: [{ id: 1, name: 'Software Testing' }] }));
await page.goto('/enquiry');
await page.getByLabel('Full name').fill('Test User');
await page.getByRole('combobox', { name: 'Course' }).click();
await page.getByRole('option', { name: 'Software Testing' }).click();
await page.getByRole('button', { name: 'Submit' }).click();
await expect(page.getByRole('status')).toHaveText('Thanks! We will call you soon.');
});
What happens when it runs:
page.routeintercepts the request for courses and returns the fixed list, so the dropdown always contains "Software Testing" no matter what the backend returns.getByLabelfinds the input linked to the "Full name" label, whether React or Angular rendered it.- The combobox and option locators work for a native select replacement and for an Angular Material select, because both expose these ARIA roles; the option is found even though it lives in an overlay outside the form.
- The final
expect(...).toHaveText(...)retries until the status message appears or the timeout passes, which absorbs the framework's update delay.
The test assumes the form has a proper label, a named combobox and a status region. If it does not, that is worth raising with developers: those are accessibility issues as well as testing issues. Where no good role or label exists, ask for a data-testid and use page.getByTestId('…').
Troubleshooting common failures
"Element is not attached to the DOM"
The framework replaced the element after you located it. In Playwright, use locators (which re-query each time) rather than stored element handles; in Selenium, re-find the element after the action that triggers a re-render.
Assertion fails, then passes on rerun
You checked too early. Replace manual sleeps and one-time reads like textContent() followed by a plain comparison with web-first assertions such as toHaveText or toBeVisible, which wait. In Selenium, use explicit waits for the condition you need.
Dropdown option "not found"
The option is in an overlay or portal. Search from page, not from inside the form's container.
Locator broke after a release, nothing visible changed
You were probably using a generated class or attribute. Move to roles, labels or test IDs.
Unit and component testing tools
You may also see the developers' own tests. React projects commonly use Jest or Vitest with React Testing Library. Angular projects have traditionally used Jasmine with Karma through the Angular CLI, and the Angular team has been moving to newer runners, so check what your project uses. Protractor, the old Angular end-to-end tool, has reached end of life; new Angular projects use Playwright, Cypress or similar tools, which also suit React. Selenium vs Cypress compares the main end-to-end options.
Which should a tester learn first?
Neither in depth. Learn enough of the one your project uses to read a component, understand when it re-renders and spot where test IDs belong. If you are choosing for general job readiness, check which one appears in the job posts you are targeting; React or Angular for beginners covers the developer view. More valuable for a tester are skills that work across both: role-based locators, API mocking, and API testing itself, covered in API testing basics. To decide which language to automate in, see Java vs Python for automation testing.