โ† All Angular Web Framework Flashcard Decks

Angular Quality & Compliance 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 Angular Quality & Compliance flashcards as text
  1. What does the Angular compiler's `fullTemplateTypeCheck` option do differently from `strictTemplates`?

    Answer: fullTemplateTypeCheck enables basic type inference in templates; strictTemplates adds stricter checks like input type narrowing

    `fullTemplateTypeCheck` (legacy) enables type-checking of template expressions, while `strictTemplates` adds additional constraints like stricter input binding type checking and generic type inference.

  2. In an Angular project with Husky configured, what is the typical purpose of a pre-commit hook?

    Answer: To run linting and unit tests before allowing a git commit to succeed

    Pre-commit hooks with Husky commonly run `ng lint` and `ng test` to catch errors before they enter the repository, enforcing quality gates locally.

  3. Which Angular testing utility allows you to query the rendered DOM by CSS selector in a component test?

    Answer: Both A and B

    Both `fixture.nativeElement.querySelector()` and `fixture.debugElement.query(By.css())` work for DOM queries; `debugElement` is Angular-aware while `nativeElement` is a direct DOM reference.

  4. What is the purpose of the `--sourceMap` flag in an Angular production build for compliance and debugging purposes?

    Answer: It generates separate .map files that map minified code back to original source for debugging

    Source maps (`.map` files) allow developers and tools to trace errors in minified production bundles back to the original TypeScript/HTML source lines.

  5. What does Angular's built-in CSRF (Cross-Site Request Forgery) protection mechanism do?

    Answer: Adds a custom HTTP header (`X-XSRF-TOKEN`) from a cookie value on outgoing requests

    Angular's `HttpClientXsrfModule` reads the XSRF token from a cookie and sends it as the `X-XSRF-TOKEN` header, allowing the server to verify the request is legitimate.

  6. Which practice best improves the maintainability and compliance of Angular template tests over time?

    Answer: Querying DOM elements by stable `data-testid` attributes rather than CSS classes

    Using `data-testid` attributes decouples tests from styling and structure changes, making them resilient to refactoring without affecting test validity.

  7. What does the `ng build --stats-json` flag produce and how is it used for compliance or performance auditing?

    Answer: A `stats.json` bundle analysis file consumable by tools like webpack-bundle-analyzer

    `--stats-json` outputs webpack's `stats.json`, which tools like `webpack-bundle-analyzer` use to visualize bundle composition and identify bloated or unauthorized dependencies.