Skip to content

Instantly share code, notes, and snippets.

@PillowUnicorn
Created June 22, 2017 23:30
Show Gist options
  • Save PillowUnicorn/d2b9368ca71e849c1d5503ceae8a65a9 to your computer and use it in GitHub Desktop.
Save PillowUnicorn/d2b9368ca71e849c1d5503ceae8a65a9 to your computer and use it in GitHub Desktop.
Jest test for React Components
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { EnterLogin } from '../enter_login';
test( 'EnterLogin view renders correctly', () => {
const tree = renderer.create(
<EnterLogin />
).toJSON()
expect( tree ).toMatchSnapshot();
} );
test( 'EnterLogin view renders with invalid login credentials', () => {
const tree = renderer.create(
<EnterLogin
error="The email and password you entered did not match our records. Please try again!"
/>
).toJSON()
expect( tree ).toMatchSnapshot();
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment