2

我有一系列在本地通过的快照测试。但在 Jenkins 上,我的组件似乎正在呈现不同的快照。我的测试是:

import { render } from 'enzyme';
import React from 'react';
import Wizard from '../index';

describe('Wizard', () => {
  describe('Snapshot tests', () => {
    it('Should render the Wizard', () => {
      const container = render(<Wizard />);

      expect(container).toMatchSnapshot();
    });
  });
});

我的组件:

const Wizard = (): JSX.Element => (
  <FTWizard
    tree={root}
    layouts={{
      layout1: Layout1,
      layout2: Layout2,
      layout3: Layout3,
    }}
    stepsContent={{
      layout1: Layout1Content,
      layout2: Layout2Content,
      layout3: Layout3Content,
    }}
  />
);

export default Wizard;

我正在使用酶生成快照,而我的组件正在使用 xstate 机器。在本地测试时一切都很好,但是在 Jenkins 上我收到以下错误:

Stacktrace
Error: expect(received).toMatchSnapshot()

Snapshot name: `Wizard Snapshot tests Should render the Wizard 1`

- Snapshot  - 0
+ Received  + 4

@@ -82,10 +82,13 @@
        >
          <div
            class="content content"
          >
            <div
+             class="stack"
+           >
+             <div
                class="headingSection"
              >
                <strong>
                  What does your network look like?
                </strong>
@@ -114,10 +117,11 @@
                            Show me an example
                          </span>
                        </div>
                      </div>
                    </span>
+                 </div>
                </div>
              </div>
            </div>
          </div>
          <div

什么可能导致我的本地测试和远程测试之间存在差异?

4

0 回答 0