Created
December 21, 2018 01:09
-
-
Save edgerunner/d83ab9cc5eaa4c7b2c558a41e8a4f01e to your computer and use it in GitHub Desktop.
Cypress command to mount react components
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 { render } from "react-dom"; | |
Cypress.Commands.add("mount", (component) => { | |
cy.get("body", { log: false }).then((body) => { | |
body[0].innerText=""; | |
const container = document.createElement("div"); | |
container.setAttribute("id", "cypress"); | |
body[0].appendChild(container); | |
render(component, container); | |
return container; | |
}); | |
Cypress.log({ message: component.type.name, consoleProps: () => ({ Component: component }) }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment