Created
April 2, 2019 07:55
-
-
Save christopherkade/6c992afd28f1cb1206c4a5a150442a09 to your computer and use it in GitHub Desktop.
Unit testing example 07
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 React from 'react'; | |
import App from './App'; | |
import { shallow } from 'enzyme' | |
// 1. Test suite | |
describe("[UNIT] Testing the App component", () => { | |
let wrapper | |
// 2. A Jest setup helper function | |
beforeEach(() => { | |
// 3. Enzyme's shallow rendering | |
wrapper = shallow(<App/>) | |
}) | |
describe("Component validation", () => { | |
// 4. Our unit test, checking if the initial value is 0 | |
it('displays 0 as a default value', () => { | |
expect(wrapper.find("h1").text()).toContain("0") | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment