代码之家  ›  专栏  ›  技术社区  ›  Igor Soloydenko

生成的快照的字段值不同:空字符串与未定义的快照

  •  0
  • Igor Soloydenko  · 技术社区  · 7 年前

    问题摘要

    我对一些react组件的jest快照测试在本地通过得很好,但在ci的构建代理计算机上失败。我 确保 我的测试是针对相同的代码(git hash已确认)和配置运行的。

    出于某种原因,本地创建的快照 "" 某些地方的值,而CI主机上的相同快照正在获取 undefined 价值。

    在我的机器上的节点版本是8 .x.x,而构建代理使用6 .x.x时,我经历了同样的问题。但是现在情况并非如此(见下面的版本)。

    我很困惑: 我从哪里开始调查? γ

    工具版本

             Dev machine     CI build agent host
    node         v8.14.0                 v8.11.1
    yarn          1.12.3                   1.6.0
    npm            6.4.1                   5.6.0
    

    测试失败日志(节选)

    2019-01-06T23:41:27.2918318Z   ● SelectUserDropdownComponent › should render SelectUserDropdownComponent
    2019-01-06T23:41:27.2919101Z 
    2019-01-06T23:41:27.2919451Z     expect(value).toMatchSnapshot()
    2019-01-06T23:41:27.2920151Z 
    2019-01-06T23:41:27.2920606Z     Received value does not match stored snapshot "SelectUserDropdownComponent should render SelectUserDropdownComponent 1".
    2019-01-06T23:41:27.2920869Z 
    2019-01-06T23:41:27.2921115Z     - Snapshot
    2019-01-06T23:41:27.2921594Z     + Received
    2019-01-06T23:41:27.2921763Z 
    2019-01-06T23:41:27.2923351Z     @@ -122,11 +122,11 @@
    2019-01-06T23:41:27.2923596Z           },
    2019-01-06T23:41:27.2923949Z           "ref": null,
    2019-01-06T23:41:27.2924249Z           "rendered": Array [
    2019-01-06T23:41:27.2924482Z             Object {
    2019-01-06T23:41:27.2924711Z               "instance": null,
    2019-01-06T23:41:27.2925046Z     -         "key": "",
    2019-01-06T23:41:27.2925294Z     +         "key": undefined,
    2019-01-06T23:41:27.2925532Z               "nodeType": "host",
    2019-01-06T23:41:27.2925778Z               "props": Object {
    2019-01-06T23:41:27.2926121Z                 "children": "Unassign",
    2019-01-06T23:41:27.2926369Z                 "value": "",
    2019-01-06T23:41:27.2926599Z               },
    2019-01-06T23:41:27.2926920Z     @@ -227,11 +227,11 @@
    2019-01-06T23:41:27.2927152Z             },
    2019-01-06T23:41:27.2927376Z             "ref": null,
    2019-01-06T23:41:27.2927618Z             "rendered": Array [
    2019-01-06T23:41:27.2927958Z               Object {
    2019-01-06T23:41:27.2928224Z                 "instance": null,
    2019-01-06T23:41:27.2928466Z     -           "key": "",
    2019-01-06T23:41:27.2928709Z     +           "key": undefined,
    2019-01-06T23:41:27.2929077Z                 "nodeType": "host",
    2019-01-06T23:41:27.2929405Z                 "props": Object {
    2019-01-06T23:41:27.2929685Z                   "children": "Unassign",
    2019-01-06T23:41:27.2930053Z                   "value": "",
    2019-01-06T23:41:27.2930303Z                 },
    2019-01-06T23:41:27.2930455Z 
    2019-01-06T23:41:27.2930668Z       29 | 
    2019-01-06T23:41:27.2931079Z       30 |     it('should render SelectUserDropdownComponent', () => {
    2019-01-06T23:41:27.2931403Z     > 31 |         expect(getWrapper()).toMatchSnapshot();
    2019-01-06T23:41:27.2931693Z          |                              ^
    2019-01-06T23:41:27.2931950Z       32 |     });
    2019-01-06T23:41:27.2932278Z       33 | 
    2019-01-06T23:41:27.2932569Z       34 |     it('should call onChange function on input value change', () => {
    2019-01-06T23:41:27.2932782Z 
    2019-01-06T23:41:27.2933081Z       at Object.<anonymous> (wmclient/js/Components/App/__tests__/SelectUserDropdownTests.tsx:31:30)
    2019-01-06T23:41:27.2933431Z 
    2019-01-06T23:41:27.2933785Z  › 1 snapshot failed.
    
    0 回复  |  直到 7 年前