window.matchMedia()
Evaluates a media query and returns a MediaQueryList that reports changes. Specification: drafts.csswg.org/cssom-view/.
Results
Probed on 2026-10-19 with Node.js v22.23.3.
warpdom 0.1.6
MissingNot defined in this engine's window.
Web IDL existence (coverage):
- MediaQueryList: interface not defined.
happy-dom 21.0.3
Supported2 of 2 checks work.
Web IDL existence (coverage):
- MediaQueryList: interface not defined.
jsdom 30.1.3
MissingNot defined in this engine's window.
Web IDL existence (coverage):
- MediaQueryList: interface not defined.
linkedom 0.18.13
MissingNot defined in this engine's window.
Web IDL existence (coverage):
- MediaQueryList: interface not defined.
Checks
all-matches: matchMedia("all").matches is true and matchMedia("not all").matches is false. (spec)media-query-list: The result has a serialized .media and supports addEventListener("change", ...). (spec)
Working around it in tests
A common pattern is to define window.matchMedia in a setup file with a function returning { matches: false, media, addEventListener() {}, removeEventListener() {} } (shown in the Jest documentation).