Skip to content

Instantly share code, notes, and snippets.

@rodrigopr
Created August 12, 2016 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigopr/7c0dfe9adc6e2f36fed3c5c2a6b6daee to your computer and use it in GitHub Desktop.
Save rodrigopr/7c0dfe9adc6e2f36fed3c5c2a6b6daee to your computer and use it in GitHub Desktop.
import { shallow } from 'enzyme';
const deepShallow = (endCondition) => (element) => {
let wrapper = shallow(element);
while (wrapper.node && !endCondition(wrapper)) {
wrapper = wrapper.shallow();
}
return wrapper;
}
export const deepShallowTo = (ExpectedComp) => deepShallow(
(wrapper) => wrapper.type() === ExpectedComp
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment