Trying to get a login unit test working but it keeps giving me the error
Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none.
To configure an adapter, you should call Enzyme.configure({ adapter: new Adapter() })
before using any of Enzyme's top level APIs, where Adapter
is the adapter
corresponding to the library currently being tested. For example:
import Adapter from 'enzyme-adapter-react-15';
This is my unit test
import React from 'react';
import { shallow, mount, render } from 'enzyme';
import Login from './components/login.js';
describe('Login Test Suite', () => {
it('should render the form', () => {
const wrapper = shallow(<Login />);
expect(wrapper.find('form.login').exists()).toBe(true);
expect(wrapper.find('#Username').length).toEqual(1);
expect(wrapper.find('#password').length).toEqual(1);
})
})
describe('Username Test Suite', () => {
it('should change the state of the Login component', () => {
const wrapper = shallow(<Login />);
wrapper.find('#Username').simulate('blur',
{
target: { name: 'Username', value: 'adastest' }
});
expect(wrapper.state('Username')).toEqual('adastest');
})
})
describe('Password Test Suite', () => {
it('should change the state of the Login component', () => {
const wrapper = mount(<Login />);
wrapper.find('#password').simulate('blur',
{
target: { name: 'password', value: 'adastest' }
});
expect(wrapper.state('password')).toEqual('adastest');
})
})