Created
June 1, 2021 04:12
-
-
Save kt3k/f1975da5533bd567c1b363ccaec2cf69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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