cmelion / redux-observable-test-helpers

Unit test helpers
8 stars 0 forks source link

Property with undefined value #1

Open ferenckv opened 7 years ago

ferenckv commented 7 years ago

This scenario is not working:

const fail = function(action$) {
  return action$.ofType('FAIL_ACTION').map(action => action.payload);
}

it('should fail', done => {
  const action = {
    type: 'FAIL_ACTION',
    payload: {
      test1: '123',
      test2: undefined,
    },
  };

  const expected = {
    test1: '123',
  };

  const {fail} = require('../epics');

  expectEpic(fail, {
    expected: ['a|', {a: expected}],
    action: ['a|', {a: action}],
    response: ['|'],
    done,
  });
});

It looks like the stringify here https://github.com/cmelion/redux-observable-test-helpers/blob/master/src/epic-helper.js#L50 is not considering the undefined value.

Also, here https://github.com/cmelion/redux-observable-test-helpers/blob/master/src/epic-helper.js#L60 there should be a try... catch block with a console.log reporting the error, otherwise it only shows an error related with the async callback not being called, without any usefull information.

cmelion commented 6 years ago

Did you want to issue a pull-request?