Mocking Browser Image Loading in Vitest: Property Descriptors, Prototypes, and WeakMap

A deep dive into the JavaScript concepts behind mocking HTMLImageElement behaviour in Vitest, including Object.defineProperty, Object.getOwnPropertyDescriptor, prototype manipulation, and WeakMap for per-instance state tracking.