liveBook · Manning

Software testing

As explained in Acing the Frontend Interview

Testing is the systematic evaluation of software behavior against expected requirements or outcomes.

Software testing checks whether code behaves as expected. In a React application, unit, integration, end-to-end, and snapshot tests verify different aspects of quality and reliability. An interview answer should go beyond naming test types: explain what you would assert, what dependencies you would isolate, and how you would investigate a failure. section 5.5 section 5.4

Test a result and a side effect

Suppose formatDate converts a Date to YYYY-MM-DD and calls an external logger. A Jest test can mock the logger module, assert that the returned string is '2025-07-25', and separately assert that logger.log received 'Formatted date: 2025-07-25'. The mock avoids real logging while recording the call. This keeps the test focused, fast, and deterministic. section 5.4

Listing 5.15 Unit test with a mocked logger
import { formatDate } from '../utils/formatDate';
import { logger } from '../utils/logger';
jest.mock('../utils/logger'); #A
describe('formatDate', () => {
  it('formats the date to YYYY-MM-DD', () => { #B
    const result = formatDate(new Date('2025-07-25'));
    expect(result).toBe('2025-07-25');
  });
  it('logs the formatted date', () => { #C
    formatDate(new Date('2025-07-25'));
    expect(logger.log).toHaveBeenCalledWith('Formatted date: 2025-07-25');
  });
});

Compare the two assertions in the mocked-logger test: one checks the return value; the other checks a side effect. section 5.4

A useful follow-up is: “How would you debug a failing unit test?” For a React Testing Library query failure, inspect the DOM printed by the test runner, call screen.debug() for the whole document or a selected element, or use screen.logTestingPlaygroundURL() to inspect the DOM and refine the query. If printed output is truncated, increase DEBUG_PRINT_LIMIT. section 5.4

Testing also belongs in the wider toolchain. Jest and React Testing Library appear alongside Cypress and Playwright; CI test runners can automate execution. More advanced workflows add visual regression, coverage tracking, and test orchestration. Choose the test and tool for the behavior you need to verify, then be ready to justify that choice. section 5.4 section 5.5

How Acing the Frontend Interview covers it

How deep it goes
Works through a mocked Jest unit test and DOM-debugging techniques; surveys other test types and advanced workflows without worked implementations.
Examples
Uses a date formatter with a mocked logger, return-value and call assertions, and DOM inspection for failing queries.
What it assumes
Assumes familiarity with React and code-level tests while demonstrating how mocking isolates an external dependency.
What you can do after
Apply it via Jest to isolate a dependency and assert results and side effects; diagnose/debug failing queries with React Testing Library tools.
How it connects
Connects unit testing to mocks, side effects, React Testing Library queries, CI/CD, visual regression, and code coverage.

Also explained in

Compare how 67 books explain software testing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Frontend Interview. The section links point to the parts of the book it draws on.