Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import "https://unpkg.com/react@17.0.2/umd/react.development.js";
import "https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js";
import "https://unpkg.com/@testing-library/react@11.2.7/dist/@testing-library/react.umd.js";
import jsdom from "https://dev.jspm.io/jsdom";
import { assert } from "https://deno.land/std@0.97.0/testing/asserts.ts";
const { render } = TestingLibraryReact; // <- Umd testing-library exports this in global
Deno.test("test", async () => {
const { JSDOM } = jsdom;
const doc = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
globalThis.document = doc.window.document;
globalThis.HTMLIFrameElement = doc.window.HTMLIFrameElement; // Needed for testing-library
const { getByText } = render(<div>hello</div>);
assert(getByText("hello") instanceof doc.window.HTMLDivElement);
// Needs to wait a little bit to prevent the leaking of the timer.
await new Promise(r => setTimeout(r, 10));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment