Issue using chai-enzyme alongside chai-jquery
See original GitHub issueThe root of the problem appears to stem from the fact that chai-jquery uses checked
as a property:
expect($(node)).to.be.checked;
While chai-enzyme implements it as an assertion method:
expect(wrapper).to.be.checked();
If I call chai.use
with chai-jquery first, chai-enzyme chokes while trying to add the checked
assertion (chaiWrapper.addAssertion(checked, 'checked')
):
Uncaught TypeError: Cannot read property 'is' of undefined
If I call chai.use
with chai-enzyme first, chai-jquery overwrites the checked
assertion as a property.
Any ideas on how to make them play nice together?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
What is the benefit of enzyme in comparison to chai-jquery #546
I'm using redux with react in my app, so if I try to test a component which has access to redux store with...
Read more >Unit Test d3v4 zoom behavior in React with Chai
Using d3v4, react and chai (chai-enzyme, chai-jquery) for unit testing. So I have a zoom behavior attached to my graph.
Read more >the Different Testing Tools (chai, mocha, enzyme, jest) - Leanne
A unit testing framework developed by Facebook for ReactJS project. Use Jest to capture snapshots of React components for certain time with props...
Read more >Chai-jQuery - Chai Assertion Library
Chai is a BDD / TDD assertion library for [node](http://nodejs.org) and the browser that can be delightfully paired with any javascript testing framework....
Read more >How to test React with Mocha, Chai & Enzyme - Robin Wieruch
Learn how to test your React application with Mocha, Chai & Enzyme. Mocha will be used as a test runner, Chai as testing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ljharb I don’t want to hijack this thread, so I’ll just say we have an issue (https://github.com/chaijs/chai/issues/585) which details what the new plugin interface will look like. Plugins will be abstracted away from decisions like property based assertions, and it will be determined by interface.
Hi guys, it’s been a while and I guess the chai plugin system wasn’t updated yet. But, can anyone post some feasible solution or workaround or hack to solve this issue meanwhile?
In my case, some of my modules have unit tests for jQuery based UI and another for React based, so if I only get an idea how to initialize chai per module then I would use
chai-jquery
andchai-enzyme
independently. Although it seems if I callchai.use
once the plugin stays there forever until I restart the browser. I couldn’t figure out a way to initialize chai within a module scope. Is there a way to do so?