Skip to content

Instantly share code, notes, and snippets.

@christopherkade
Created April 2, 2019 07:55
Show Gist options
  • Save christopherkade/6c992afd28f1cb1206c4a5a150442a09 to your computer and use it in GitHub Desktop.
Save christopherkade/6c992afd28f1cb1206c4a5a150442a09 to your computer and use it in GitHub Desktop.
Unit testing example 07
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