Synchronous script execution in jsdom

Usage no npm install needed!

<script type="module">
  import olegjsJsdomSync from 'https://cdn.skypack.dev/@olegjs/jsdom-sync';



Standard - JavaScript Style Guide

Synchronous script execution in jsdom. Made for unit tests.

By default all script in jsdom are executed in parallel. In some cases, like unit testing, simplicity is more important than performance. This is a wrapper around jsdom that feeds all script code as inline script tags, ensuring sequential execution.

const jsdomSync = require('jsdom-sync')
const document = jsdomSync(['a.js', 'b.js'])
const window = document.defaultView
// do stuff


  • All files included in script tags inside head; use DOMContentLoaded event.
  • If you need speed from jsdom, use the callbacks or promises instead.