简体   繁体   中英

ImmutableJS fromJS() and Map() “ownerID” doesn't match

I am using chai-immutable npm module for testing. Here is the test:

it("runs the test", () => {
    const initialState = Map();
    const entries = ["entry"];
    const nextState = setEntries(initialState, entries);

    expect(nextState).to.equal(fromJS({
        entries : ["entry"]
    }));
});

This is setEntries function

export function setEntries(state, entries) {
    return state.set("entries", List(entries));
}

The npm test fails: 在此处输入图片说明

What is this ownerID ? How to fix the issue?

EDIT:

I have created and rewritten the whole file from scratch and it worked. It was exact same replica of the previous file.

Still interested why it happened....

Did you have this piece of code somewhere when invoking the test runner?

import chai from 'chai';
import chaiImmutable from 'chai-immutable';

chai.use(chaiImmutable);

typically you would use that in a file, say test/test-config.js and then call your runner like this: mocha --compilers js:babel-core/register --require ./test/test-config.js --recursive

(I'm assuming you need babel compiler, but the important part there is the --require ./test/test-config.js )

I fix this issue with Immutable.is()

expect(is(
    nextStat,
    fromJS({entries : ["entry"]})
)).to.equal(true)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM