← All Angular Web Framework Flashcard Decks

Testing & Debugging Flashcards

7 cards from real Angular Web Framework practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Testing & Debugging flashcards as text
  1. When using `async/await` in an Angular test instead of `fakeAsync`, what function must wrap the test callback?

    Answer: async() from @angular/core/testing

    The async() utility from @angular/core/testing patches the test zone so Angular knows to wait for all asynchronous operations before completing the test.

  2. What does `TestBed.overrideComponent()` allow you to do in Angular tests?

    Answer: Replace a component's metadata (template, providers, styles) after TestBed has been configured

    TestBed.overrideComponent() modifies a component's template or providers at test time without redefining the entire TestBed configuration.

  3. In Angular E2E testing with Cypress, what is the recommended way to interact with Angular-specific elements like mat-select?

    Answer: Trigger native DOM events and use cy.get() with accessible selectors or data-cy attributes

    Cypress works at the browser DOM level, so triggering native events on accessible selectors or data-cy attributes is the reliable, Angular-agnostic approach.

  4. Which Angular CDK testing utility provides a unified API for interacting with Angular Material components in tests?

    Answer: Component Test Harnesses (HarnessLoader)

    Angular CDK's HarnessLoader provides Component Test Harnesses — stable, semantic APIs for interacting with Material components in both unit and E2E tests.

  5. What error does Angular throw during testing when you forget to import a module that provides a required pipe?

    Answer: 'The pipe X could not be found'

    Angular throws a template parse error stating the pipe cannot be found if the module declaring it isn't imported in the TestBed configuration.

  6. In Angular unit tests, what does `spyOn(service, 'methodName').and.callThrough()` do?

    Answer: Wraps the real method with a spy so both the original implementation runs and calls are recorded

    callThrough() lets the original function execute while the spy still tracks how many times it was called and with what arguments.

  7. What is the purpose of the `--code-coverage` flag in `ng test`?

    Answer: It generates a coverage report showing which lines and branches are exercised by tests

    Passing --code-coverage instructs Istanbul/NYC to instrument the source and produce an HTML/JSON coverage report under the coverage/ directory.