mock-violentmonkey
Version:
Mock violentmonkey's globals for testing userscripts
20 lines (19 loc) • 653 B
TypeScript
import { type DOMWindow } from 'jsdom';
declare const getWindow: () => DOMWindow;
/**
* Load the page at the given url to the dom
*/
declare const loadURLToDom: (url: string) => Promise<void>;
/**
* Set document.documentElement.outerHTML to passed string
*/
declare const loadStringToDom: (outerHTML: string) => void;
type MapKnownKeys<T> = {
[K in keyof T as string extends K ? never : K]: string;
};
/**
* Enable a global dom value.
* This allows you to enable only what you need.
*/
declare function enableDomGlobal(key: keyof MapKnownKeys<DOMWindow>): void;
export { getWindow, getJSDOM, loadURLToDom, loadStringToDom, enableDomGlobal };