Ath*_*sia 5 reactjs jestjs enzyme xstate snapshot-testing
我有一系列在本地通过的快照测试。但在 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();
});
});
});
Run Code Online (Sandbox Code Playgroud)
我的组件:
const Wizard = (): JSX.Element => (
<FTWizard
tree={root}
layouts={{
layout1: Layout1,
layout2: Layout2,
layout3: Layout3,
}}
stepsContent={{
layout1: Layout1Content,
layout2: Layout2Content,
layout3: Layout3Content,
}}
/>
);
export default Wizard;
Run Code Online (Sandbox Code Playgroud)
我正在使用酶生成快照,我的组件正在使用 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
Run Code Online (Sandbox Code Playgroud)
是什么导致我的本地测试和远程测试之间存在差异?
| 归档时间: |
|
| 查看次数: |
942 次 |
| 最近记录: |