Skip to end of banner
Go to start of banner

UI Testing with Enzyme

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

  Pros
- Very easy to set up for unit testing regardless of what other testing tools are used
- Does not require a special environment and configuration
- Good documentation and simple API
- Very fast
- Provides facilities for testing the instance of the component directly:
describe('Tags multiselect', () => {
it('should pass correct data options to the Multiselect component', () => {
const tags = [
{ id: '1', label: 'B' },
{ id: '2', label: 'A' },
];

const wrapper = mount(
<Tags
{...baseProps}
tags={tags}
/>
);

const propsPassedToMultselection = wrapper.find(MultiSelection).props();

expect(propsPassedToMultselection.dataOptions).to.deep.equal([
{ value: 'a', label: 'a' },
{ value: 'b', label: 'b' },
]);
});
});

Cons
- Issues with testing hooks
- Provides facilities for testing the instance of the component directly. This can encourage harmful testing approaches.
- React testing library

  • No labels