redux-saga-test-plan icon indicating copy to clipboard operation
redux-saga-test-plan copied to clipboard

SagaTestError: comparing classes

Open Dodje opened this issue 5 years ago • 0 comments

Hey! I've got some error comparing final and expected states. I have a table that can have filters. Filter is an instance for the class which has some needed methods and constants. And I guess because of class's hidden properties _lodash4 (inside createStoreStateExpectation) can't handle with comparing states with classes inside them.

Im using redux-saga 1.0.5, redux-saga-test-plan 4.0.0-rc.1.

SagaTestError: 
    Expected to have final store state:
    table: {
        allTables : {
            uuid: {
                filters: [
                    FilterExample {
                        column: 'info',
                        values: {},
                        items: [ { value: 'Value'} ],
                        label: 'Information',
                        type: 'filterType' }
                ]
            }
        }
    }


  But instead had final store state:
    ----------------------------------
    table: {
        allTables : {
            uuid: {
                filters: [
                    FilterExample { // class
                        column: 'info',
                        values: {},
                        items: [ { value: 'Value'} ],
                        label: 'Information',
                        type: 'filterType' }
                ]
            }
        }
    }

I tried to deal with that something like this (not perfect solution)

...
function createStoreStateExpectation(_ref4) {
  var expectedState = _ref4.state,
      expected = _ref4.expected;

  return function (_ref5) {
    var storeState = _ref5.storeState;

    expectedState=JSON.parse(JSON.stringify({...expectedState}))
    storeState=JSON.parse(JSON.stringify({...storeState}))

    if (expected && !(0, _lodash4.default)(expectedState, storeState)) {
        ...

And also would be nice to let us set the object's depth without changing magical numbers in lib :) //var serializedActual = (0, _utilInspect2.default)(storeState, { depth: 3 }); -> 10

SagaTestError: 
    Expected to have final store state:
    -----------------------------------
    { table: { allTables: { uuid: { filters: [Object] } } } }

    But instead had final store state:
    ----------------------------------
    { table: { allTables: { uuid: { filters: [Object] } } } }

Dodje avatar Oct 09 '19 09:10 Dodje