Skip to content

Instantly share code, notes, and snippets.

@takethefake
Last active October 21, 2018 16:12
Show Gist options
  • Save takethefake/d877628fbd680e3c7b36fefb9305e66f to your computer and use it in GitHub Desktop.
Save takethefake/d877628fbd680e3c7b36fefb9305e66f to your computer and use it in GitHub Desktop.
Medium: Jest test with React DOM rendering
import * as React from "react";
import ReactDOM from "react-dom";
import { Input } from "../";
test("it initializes with a defaultValue", () => {
const containerDiv = document.createElement("div");
const defaultValue = "DefaultValue";
ReactDOM.render(<Input initialValue={defaultValue} />, containerDiv);
expect(containerDiv.querySelector("input").value).toBe(
defaultValue
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment