JSPM

@happy-dom/global-registrator

14.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 201955
  • Score
    100M100P100Q197306F
  • License MIT

Use Happy DOM globally in a Node.js environment for testing.

Package Exports

  • @happy-dom/global-registrator
  • @happy-dom/global-registrator/cjs/GlobalRegistrator.cjs
  • @happy-dom/global-registrator/cjs/GlobalRegistrator.cjs.map
  • @happy-dom/global-registrator/cjs/GlobalRegistrator.d.ts
  • @happy-dom/global-registrator/cjs/GlobalRegistrator.d.ts.map
  • @happy-dom/global-registrator/cjs/index.cjs
  • @happy-dom/global-registrator/cjs/index.cjs.map
  • @happy-dom/global-registrator/cjs/index.d.ts
  • @happy-dom/global-registrator/cjs/index.d.ts.map
  • @happy-dom/global-registrator/lib/GlobalRegistrator.cjs.map
  • @happy-dom/global-registrator/lib/GlobalRegistrator.d.ts
  • @happy-dom/global-registrator/lib/GlobalRegistrator.d.ts.map
  • @happy-dom/global-registrator/lib/GlobalRegistrator.js
  • @happy-dom/global-registrator/lib/GlobalRegistrator.js.map
  • @happy-dom/global-registrator/lib/index.cjs.map
  • @happy-dom/global-registrator/lib/index.d.ts
  • @happy-dom/global-registrator/lib/index.d.ts.map
  • @happy-dom/global-registrator/lib/index.js
  • @happy-dom/global-registrator/lib/index.js.map
  • @happy-dom/global-registrator/package.json
  • @happy-dom/global-registrator/src/GlobalRegistrator.ts
  • @happy-dom/global-registrator/src/index.ts

Readme

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();

GlobalRegistrator.unregister();

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

Happy DOM

Documentation | Getting Started | Setup as Test Environment | GitHub