Package Exports
- @happy-dom/global-registrator
- @happy-dom/global-registrator/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@happy-dom/global-registrator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
This package makes it possible to register Happy DOM and makes it easy to setup your own test environment.
Installation
npm install @happy-dom/global-registrator --save-dev
Documentation
You will find the documentation in the Happy DOM Wiki under Global Registrator.
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