tezvyn:

Describe the role of a spy in testing with a framework example

Source: jestjs.iointermediate

This tests whether you know a spy records calls without replacing original implementation. A strong answer defines the tracking role, picks a concrete Vue or Angular handler, and asserts with toHaveBeenCalled.

This tests whether you understand that a spy wraps a real function to record invocations without altering behavior. A strong answer distinguishes a spy from a mock by noting spies preserve implementation while capturing calls and arguments, then gives a concrete component scenario such as verifying a Vue emitted event or Angular handler with jest.spyOn. It also mentions cleanup via mockRestore to avoid test leakage. A red flag is describing a spy as a stub that replaces behavior or giving an example where the original function never executes.

Read the original → jestjs.io

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Describe the role of a spy in testing with a framework example · Tezvyn