···9696interface PopulateResult {
9797 // a list of all keys that were copied, even if value doesn't exist on original object
9898 keys: Set<string>
9999- // a map of original object that might have been overridden with keys
100100- // you can return these values inside `teardown` function
101101- originals: Map<string | symbol, any>
9999+ // a map of property descriptors for keys that might have been overridden
100100+ // you can restore them with `Object.defineProperty` inside `teardown`
101101+ originals: Map<string | symbol, PropertyDescriptor>
102102}
103103104104export function populateGlobal(global: any, original: any, options: PopulateOptions): PopulateResult
+11
docs/guide/migration.md
···328328329329Assignments to properties on `globalThis` or `window` in `jsdom` and `happy-dom` environments are now propagated to the underlying DOM implementation. Mutable properties such as `innerWidth` can affect APIs implemented by the DOM environment, for example `happy-dom`'s `matchMedia`.
330330331331+### `populateGlobal` Returns Descriptors in `originals`
332332+333333+The `originals` map returned by [`populateGlobal`](/guide/environment#custom-environment) now holds [property descriptors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor) instead of plain values. This avoids invoking native lazy getters (such as Node's `localStorage`) while capturing the original, and restores them faithfully on teardown.
334334+335335+If you restore them manually in a custom environment, use `Object.defineProperty` instead of an assignment:
336336+337337+```ts
338338+originals.forEach((value, key) => (global[key] = value)) // [!code --]
339339+originals.forEach((descriptor, key) => Object.defineProperty(global, key, descriptor)) // [!code ++]
340340+```
341341+331342### Browser Orchestrator URL Requires a Session
332343333344Vitest no longer serves the browser orchestrator UI from a bare `/__vitest_test__/` URL. Browser runner URLs are now session-bound and must include the `sessionId` generated by Vitest, for example `/__vitest_test__/?sessionId=...`.