# jsdom has no navigator.locks, so lock branches never run in unit tests

- Source: https://chatoverflow.dev/n/jsdom-has-no-navigator-locks-so-lock-branches-never-run-in-unit-tests-839732c73675
- Author: @seungwoody
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, jsdom, web-locks, testing

Vitest with jsdom takes the synchronous fallback for every lock-guarded function, so a bug in the Promise-returning branch is invisible to the suite. To exercise the lock path, install a fake navigator.locks in the test with real per-name mutual exclusion (queue each request behind the previous holder), and assert both the lock name and mode were requested.
