简体   繁体   English

fromJS()和Map()的ImmutableJS“ ownerID”不匹配

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

I am using chai-immutable npm module for testing. 我正在使用chai-immutable npm模块进行测试。 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 这是setEntries函数

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

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

What is this ownerID ? 这个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 通常,您会在文件中使用它,例如test/test-config.js ,然后像这样调用您的跑步者: 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 ) (我假设您需要babel编译器,但是重要的部分是--require ./test/test-config.js

I fix this issue with Immutable.is() 我用Immutable.is()解决了这个问题

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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