A Pen by Koen Vendrik on CodePen.
Created
March 20, 2022 14:10
-
-
Save hatemhosny/8b59f733bc3f62f9a494342e12cf9326 to your computer and use it in GitHub Desktop.
jest-lite CDN Example
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
const { | |
core: { describe, it, expect, run }, | |
enzyme: { mount }, | |
prettify | |
} = window.jestLite; | |
function Button({ children }) { | |
return <button>{children}</button>; | |
} | |
describe("<Button />", () => { | |
it("renders children", () => { | |
const text = "Click me!"; | |
const button = mount(<Button>{text}</Button>); | |
expect(button.text()).toBe(text); | |
}); | |
it("renders as a link", () => { | |
const button = mount(<Button />); | |
expect(button.find("a").exists()).toBe(true); | |
}); | |
it("renders as a button", () => { | |
const button = mount(<Button />); | |
expect(button.find("button").exists()).toBe(true); | |
}); | |
}); | |
prettify.toHTML(run(), document.body); |
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
<script src="https://unpkg.com/react@16/umd/react.production.min.js"></script> | |
<script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script> | |
<script src="https://unpkg.com/jest-lite@1.0.0-alpha.4/dist/core.js"></script> | |
<script src="https://unpkg.com/jest-lite@1.0.0-alpha.4/dist/enzyme.js"></script> | |
<script src="https://unpkg.com/jest-lite@1.0.0-alpha.4/dist/prettify.js"></script> |
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
html, | |
body { | |
margin: 0; | |
height: 100%; | |
} |
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
<link href="https://unpkg.com/jest-lite@1.0.0-alpha.4/dist/prettify.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment