@happy-dom/global-registrator
TypeScript icon, indicating that this package has built-in type declarations

14.12.0 • Public • Published

Happy DOM Logo

This package makes it possible to register Happy DOM in the global scope, e.g. for testing purposes.

Installation

npm install @happy-dom/global-registrator --save-dev

Usage

Register

import { GlobalRegistrator } from '@happy-dom/global-registrator';

GlobalRegistrator.register({ url: 'http://localhost:3000', width: 1920, height: 1080 });

document.body.innerHTML = `<button>My button</button>`;

const button = document.querySelector('button');

// Outputs: "My button"
console.log(button.innerText);

Unregister

import { GlobalRegistrator } from '@happy-dom/global-registrator';

GlobalRegistrator.register();

await GlobalRegistrator.unregister();

// Outputs: "undefined"
console.log(global.document);

Happy DOM

Documentation | Getting Started | Setup as Test Environment | GitHub

/@happy-dom/global-registrator/

    Package Sidebar

    Install

    npm i @happy-dom/global-registrator

    Weekly Downloads

    20,794

    Version

    14.12.0

    License

    MIT

    Unpacked Size

    25 kB

    Total Files

    24

    Last publish

    Collaborators

    • davidortner