You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 26, 2019. It is now read-only.
in mocha-chai-enzyme combo i can write test like this:
functionTestComponent({ value, doClick }){// react stateless componentreturn(<divclassName="test-component"onClick={e=>doClick(value)}>{value&&<TestComponentValue={value-1}doClick={doClick}/>}</div>);}describe('Test',function(){it('Success',function(){constprops={value: 42,doClick: ()=>{}// functions are checked only for existence, not content};constactual=shallow(<TestComponent{...props}/>);constexpected=// basically copy-pastle of TestComponent return value...<divclassName="test-component"onClick={()=>{}}><TestComponentValue={41}doClick={()=>{}}/></div>;expect(actual).toEqualJSX(expected);// toEqualJSX from './jsxEqual'});});
It isn't possible to use mocha but I think it's possible to use chai-enzyme. Airbnb actually released a blog post today in which they describe using chai with jest. So you can just require in { expect } from chai.
On a side note, personally I don't think it's valuable to test components in the way you describe above. While I don't use this testing strategy, Snapshot testing sounds very similar to what you you're doing in your example.
Question is in title, here is my reason why:
in mocha-chai-enzyme combo i can write test like this:
instead of something like:
i dont wanna loose that but also like no-config configuration of cra-ts ....
The text was updated successfully, but these errors were encountered: