Skip to content

Hatch-Team/enzyme-adapter-react-16-with-shallow-effects

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enzyme-adapter-react-16-with-shallow-effects

This extremely-long-named package is a "fork" of the react-16 adapter included with enzyme, with one difference that applies only to shallow() testing:

Also, under the hood, it uses react-shallow-renderer rather than react-test-renderer/shallow. Ongoing development of react-test-renderer/shallow has been moved to react-shallow-renderer. This should not result in any observable differences in behavior.

Example Usage:

import React from 'react';
import { shallow, configure } from 'enzyme';
import AdapterWithShallowEffects from 'enzyme-adapter-react-16-with-shallow-effects';

// setup enzyme to use the adapter
configure({ adapter: new AdapterWithShallowEffects() });

const ExampleComponent = () => {
  useEffect(() => {
    console.log('effect triggered!);

    return () => { console.log('effect cleaned up!); };
  });
  return <div />
};

console.log('rendering shallow');
const rendered = shallow(<ExampleComponent />)
console.log('unmounting');
shallow.unmount();
console.log('done');

About

Enzyme adapter with support for effects with shallow rendering

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%