简体   繁体   中英

Enzyme Shallow() returns an element that doesn't work with selectors correctly

I expected this to work but it doesn't:

const element = shallow(<SomeComponentClass />);
element.is(SomeComponentClass); // === false, why?

I get false although I was expecting it to return true.
Using mount() instead of shallow() returns true

Why? Thanks!

I opened an issue for enzyme about this and it seems like shallow doesn't return the component class but the rendered dim element. https://github.com/airbnb/enzyme/issues/768#issuecomment-272125380

So the false is intentional. Mount should also return false, actually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM