Git Product home page Git Product logo

global-jsdom's People

Contributors

attekemppila avatar cahnory avatar coryhouse avatar dankaplanses avatar dependabot-preview[bot] avatar dependabot[bot] avatar ffluk3 avatar jtag05 avatar kenjiru avatar modosc avatar rstacruz avatar smhg avatar to-codando avatar willsoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

global-jsdom's Issues

example usage with webpack config

such like

		fallback: {
			fs: false,
			child_process: false,
            net: false,
            tls: false,
			stream: false,
			assert: false,
			url: false,
			buffer: false,
			querystring: false,
			zlib: false,
			os: false,
			crypto: require.resolve("crypto-browserify")
        },
		mainFields: ['module', 'main'],

jsdom 22 not supported in v9.2.x?

v9.2.0 changed supported jsdom range from ">=22 <23" -> ">=23 <24".

https://github.com/modosc/global-jsdom/pull/366/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L33-R33

(btw. You forgot to update README.md, it still says "jsdom >= 22 or above" (link))

It would have been nicer if v9.2.0 had just updated the end-of-range, not the start-of-range (that is, ">= 22 <24". Can we get an update?). Or v9.2.0 should have been a major update (-> v10), since it changes supported jsdom range in a breaking way (you must update jsdom version also).

I use Renovate to auto-update my dependencies. My renovate config is fairly default. Basically it can't handle minor-update in global-jsdom and major-update in jsdom versions. If both were major-updates, it would have been ok. Or if the global-jsdom's jsdom range were laxer (">= 22 <24"), it would have been ok.

Okey, this is not a major problem. I can fix my dependencies by hand. But still, something to consider in the future. Thank you.

Keys are missing compared to jsdom-global

After failures to test blueprintjs that expects DocumentFragment to exist at global level, I've investigated:

Dumping the content for key detection

[
        "StyleSheet",
        "MediaList",
        "CSSStyleSheet",
        "CSSRule",
        "CSSStyleRule",
        "CSSMediaRule",
        "CSSImportRule",
        "CSSStyleDeclaration",
        "XPathException",
        "XPathExpression",
        "XPathResult",
        "XPathEvaluator",
        "onafterprint",
        "onbeforeprint",
        "onbeforeunload",
        "onhashchange",
        "onlanguagechange",
        "onmessage",
        "onmessageerror",
        "onoffline",
        "ononline",
        "onpagehide",
        "onpageshow",
        "onpopstate",
        "onrejectionhandled",
        "onstorage",
        "onunhandledrejection",
        "onunload",
        "onblur",
        "onerror",
        "onfocus",
        "onload",
        "onresize",
        "onscroll",
        "onabort",
        "onautocomplete",
        "onautocompleteerror",
        "oncancel",
        "oncanplay",
        "oncanplaythrough",
        "onchange",
        "onclick",
        "onclose",
        "oncontextmenu",
        "oncuechange",
        "ondblclick",
        "ondrag",
        "ondragend",
        "ondragenter",
        "ondragexit",
        "ondragleave",
        "ondragover",
        "ondragstart",
        "ondrop",
        "ondurationchange",
        "onemptied",
        "onended",
        "oninput",
        "oninvalid",
        "onkeydown",
        "onkeypress",
        "onkeyup",
        "onloadeddata",
        "onloadedmetadata",
        "onloadstart",
        "onmousedown",
        "onmouseenter",
        "onmouseleave",
        "onmousemove",
        "onmouseout",
        "onmouseover",
        "onmouseup",
        "onwheel",
        "onpause",
        "onplay",
        "onplaying",
        "onprogress",
        "onratechange",
        "onreset",
        "onsecuritypolicyviolation",
        "onseeked",
        "onseeking",
        "onselect",
        "onsort",
        "onstalled",
        "onsubmit",
        "onsuspend",
        "ontimeupdate",
        "ontoggle",
        "onvolumechange",
        "onwaiting",
        "getSelection",
        "length",
        "window",
        "frameElement",
        "frames",
        "self",
        "parent",
        "top",
        "document",
        "external",
        "location",
        "history",
        "navigator",
        "locationbar",
        "menubar",
        "personalbar",
        "scrollbars",
        "statusbar",
        "toolbar",
        "performance",
        "screen",
        "origin",
        "localStorage",
        "sessionStorage",
        "customElements",
        "requestAnimationFrame",
        "cancelAnimationFrame",
        "postMessage",
        "atob",
        "btoa",
        "stop",
        "close",
        "getComputedStyle",
        "captureEvents",
        "releaseEvents",
        "name",
        "status",
        "devicePixelRatio",
        "innerWidth",
        "innerHeight",
        "outerWidth",
        "outerHeight",
        "pageXOffset",
        "pageYOffset",
        "screenX",
        "screenLeft",
        "screenY",
        "screenTop",
        "scrollX",
        "scrollY",
        "alert",
        "blur",
        "confirm",
        "focus",
        "moveBy",
        "moveTo",
        "open",
        "print",
        "prompt",
        "resizeBy",
        "resizeTo",
        "scroll",
        "scrollBy",
        "scrollTo",
        "addEventListener",
        "removeEventListener",
        "dispatchEvent"
      ]

The original jsdom-global project has much more keys, see here https://raw.githubusercontent.com/rstacruz/jsdom-global/master/keys.js

Can keys be exposed as options too ?

global-jsdom/register has invalid mjs import syntax

import jsdom from '.'; should be changed to import jsdom from './index.mjs';

Suffix-less imports aren't allowed in modules unless one explicitly enables the node-resolution-algorithm.

This currently fails with:

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import 'PATH/node_modules/global-jsdom/esm/' is not supported resolving ES modules imported from PATH/node_modules/global-jsdom/esm/register.mjs

Load HTML and run embedded scripts

Is it possible to load an HTML file and run embedded scripts?

In JSDOM, this is possible as follows:

const dom = await JSDOM.fromFile("myhtml.html", 
                          { runScripts: "dangerously", resources: "usable" });
// await scripts to be run
await new Promise(resolve => dom.window.addEventListener("load", resolve) );
const document = dom.window.document;
// check modified DOM:
expect(document.getElementById("generatedByScript").toBeTruthy();  
...

Unfortunately, this is not working with global-jsdom. E.g.,

globalJsdom(readFileSync("myhtml.html", { encoding: "utf-8" }),
                          { runScripts: "dangerously", resources: "usable" });
// await scripts to be run
await new Promise(resolve => dom.window.addEventListener("load", resolve) );
// check modified DOM:
expect(document.getElementById("generatedByScript").toBeTruthy();  
...

is not working. The document is loaded, but the script has not been executed. The event has been fired, that is, the promise is resolve, though.

fix esm usage

> const jsdom = await import('global-jsdom')
undefined
> jsdom
[Module: null prototype] { default: [Function: globalJsdom] }

semver for jsdom in peerDependencies

Currently any jsdom version is accepted because the semver contains the "or" operator (>=10.0.0 || <20 matches everything including 9, 20, 21). To achieve the same result, * could be used instead.

If you want to match everything between 10 and 20 (open interval), the semver should be: >=10 <=20.

jsdom < 16 required - unmet peer dependency warning

Current version of jsdom is 16.2.2
But global-jsdom depends on jsdom < 16
This results in unmet peer dependency warning when installing packages
Wondering if the jsdom < 16 requirement is still valid or could be relaxed ?

Enable pretendToBeVisual by default

This flag enables requestAnimationFrame method, which is a requirement for running React in the testing environment.

Currently I need to do the following:

require('global-jsdom')(undefined, { pretendToBeVisual: true });

It would be great to make global-jsdom/register doing this by default.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.