deno-docs
deno-docs copied to clipboard
jsdom manual example - Not Implemented: isContext
Using the manual example for: https://github.com/denoland/manual/blob/v1.26.1/jsx_dom/jsdom.md I get:
error: Uncaught Error: Not implemented: isContext throw new Error(message); ^ at notImplemented (https://deno.land/[email protected]/node/_utils.ts:23:9) at Object.isContext (https://deno.land/[email protected]/node/vm.ts:62:3) at new Sme (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:8449) at iY.createWindow (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:6192) at new py (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:23482) at file:///Users/tracey/av/jsdom.js:4:34
I tried a few versions back in jsdom
-- just in case it was that. But get same style failure up to versions 1y old, too, eg:
deno eval 'import { JSDOM } from "https://esm.sh/[email protected]"; new JSDOM("<!DOCTYPE html><html><body></body></html>")'
I'm using latest v1.26.1 of deno. Any help appreciated! I'd love to convert my work codebase jest
-based (a fair amount using jsdom
) from node
to deno
. (I tried
import { DOMParser } from 'https://deno.land/x/deno_dom/deno-dom-wasm.ts';
too. And that is working decently for some of the testing -- but we could use a more complete DOM fake for some tests (eg: form submitting, etc.)
Full example here:
> cat deno.jsonc;
{
"compilerOptions": {
"lib": [
"deno.ns",
"dom",
"dom.iterable",
"dom.asynciterable"
]
}
}
> cat jsdom.js
import { JSDOM } from "https://esm.sh/jsdom";
import { assert } from "https://deno.land/[email protected]/testing/asserts.ts";
const { window: { document } } = new JSDOM(
`<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello from Deno</title>
</head>
<body>
<h1>Hello from Deno</h1>
<form>
<input name="user">
<button>
Submit
</button>
</form>
</body>
</html>`,
{
url: "https://example.com/",
referrer: "https://example.org/",
contentType: "text/html",
storageQuota: 10000000,
},
);
const h1 = document.querySelector("h1");
assert(h1);
console.log(h1.textContent);
> deno run -A jsdom.js
error: Uncaught Error: Not implemented: isContext
throw new Error(message);
^
at notImplemented (https://deno.land/[email protected]/node/_utils.ts:23:9)
at Object.isContext (https://deno.land/[email protected]/node/vm.ts:62:3)
at new Sme (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:8449)
at iY.createWindow (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:6192)
at new py (https://esm.sh/v96/[email protected]/deno/jsdom.js:800:23482)
at file:///Users/tracey/av/jsdom.js:4:34