Skip to main content

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​

Missing

Not defined in this engine's window.

Web IDL existence (coverage):

Report a wrong result for warpdom

happy-dom 21.0.3​

Supported

2 of 2 checks work.

Web IDL existence (coverage):

Report a wrong result for happy-dom

jsdom 30.1.3​

Missing

Not defined in this engine's window.

Web IDL existence (coverage):

Report a wrong result for jsdom

linkedom 0.18.13​

Missing

Not defined in this engine's window.

Web IDL existence (coverage):

Report a wrong result for linkedom

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).