albertfdp / unexpected-enzyme Goto Github PK
View Code? Open in Web Editor NEW[WIP] unexpected.js assertions for enzyme
Home Page: http://albertfdp.github.io/unexpected-enzyme
License: MIT License
[WIP] unexpected.js assertions for enzyme
Home Page: http://albertfdp.github.io/unexpected-enzyme
License: MIT License
I think we should make a queried for
assertion like unexpected DOM.
expect(component, 'queried for', '.bar', 'to render as', <div className="bar"/>)
queried for
should fail if .bar
can't be found.
expect(component, 'queried for all', '.bar', 'to have length', 23)
expect(component, 'queried for all', '.bar', 'to have items satisfying to have props', {
'data-test-id:' expect.it('to be a number')
})
This should again fail if no results is found.
In the following example scenario:
<Parent>
<Foo>
<Item>One</Item>
</Foo>
<Foo>
<Item>Two</Item>
</Foo>
</Parent>
support doing:
expect(wrapper.find(Parent), 'to contain', [
<Item>One</Item>,
<Item>Two</Item>
]);
https://github.com/airbnb/enzyme/blob/master/docs/api/ReactWrapper/contains.md
<ReactWrapper> [not] to equal <ReactWrapper>
<ReactWrapper> [not] to exhaustively satisfy <array[ReactElement]>
<ReactWrapper> [not] to exhaustively satisfy <ReactWrapper>
<ReactWrapper> [not] to satisfy <array[ReactElement]>
<ReactWrapper> [not] to satisfy <ReactWrapper>
Consider adding https://github.com/producthunt/chai-enzyme#attrkey-val which is asserted against the rendered node, so there might be issues with camel-casing or type conversion. See: https://github.com/producthunt/chai-enzyme/blob/master/test/attr.test.js
When the to-have-props-satisfying
snapshot runs, it will output in one line sometimes, others in 2 lines, making the test unstable: https://github.com/albertfdp/unexpected-enzyme/commits/master/test/__snapshots__/to-have-props-satisfying.spec.js.snap
I think it would be useful to have to the following:
expect(component, 'to contain', '.foo > .bar')
I think this can be used http://airbnb.io/enzyme/docs/api/ShallowWrapper/some.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.