小编ski*_*iff的帖子

酶不将上下文传递给Travis上的渲染组件

我有一个特殊的情况,一直在发生.我一直在用Mocha,Enzyme,Chai和nyc测试我的React应用程序.

在我的机器上,一切都完美地完成了我的所有6次测试的6次测试.其中2个测试是从酶调用mount的测试:

it('Should contain my name in the text', () => {
    const context = { router: { } };
    const footer = mount(<Footer />, context);
    console.log(footer);
    expect(footer.text()).to.contain('Myname');
  });
  it('Should contain a link to the copyright page', () => {
    const footer = mount(<Footer />);
    expect(footer.find('a').prop('href')).to.equal('/Copyright');
  });
Run Code Online (Sandbox Code Playgroud)

在我的本地机器上运行正常.当我的测试在Travis-ci上运行时,这两个测试失败的原因如下:

Warning: Failed context type: The context `router` is marked as required in `Link`, but its value is `undefined`.
in Link (created by Unknown)
in footer (created by Unknown)
in Unknown (created by …
Run Code Online (Sandbox Code Playgroud)

travis-ci reactjs react-router enzyme

5
推荐指数
0
解决办法
323
查看次数

标签 统计

enzyme ×1

react-router ×1

reactjs ×1

travis-ci ×1