here is some context. I am working on a project using React and Immutable.js written in ES6. I use Babel and webpack.
I wrote some unit tests using Mocha, Chai, and jsdom so that they can be run outside of the browser.
The problem is that some components use things like required images. This material is processed by webpack through a specific loader.
Therefore, when running tests in the terminal, they fail due to the fact that these unprocessed ones require.
I found how to fix this using Karma (leaving the ability to run tests outside of the browser) and compiling the sources before running the tests, and make the webpack configuration simply ignore the image loader (using the null loader).
At this point, the tests are performed through Karma, but some of them fail while they pass when they are launched through the terminal (I commented on the lines in which the required material was, only for the purpose of the test).
The test that fails is related to Immutable.js, which means I'm trying to verify the equality of two immutable objects.
Here is a test example:
it('handles SET_STATE', () => { const initialState = Map(); const action = { type : 'SET_STATE', state : Map({ vote : Map({ pair : List.of('Trainspotting', '28 Days Later'), tally : Map({ 'Trainspotting' : 1 }) }) }) }; const nextState = reducer(initialState, action); expect(nextState).to.equal(fromJS({ vote: { pair: ['Trainspotting', '28 Days Later'], tally: { 'Trainspotting': 1 } } })); });
The error gives something like this:
1) handles SET_STATE reducer AssertionError: expected { Object (size, _root, ...) } to equal { Object (size, _root, ...) } at Context.<anonymous> (/Users/boris_louboff/Labs/VotingApp/voting-client/test/tests.bundle.js:36413:42 <- webpack:
All other tests that do not test things related to immutable ones pass.
If anyone has an idea that could solve this, that would be great! Thanks.