cypress-plugin-snapshots
<p><strong>运行:</strong>
运行第一遍保存baseline,运行第二遍进行图形对比测试;</p>
<p><strong>优点:</strong></p>
<ol>
<li>减少断言代码的编写</li>
<li>帮你检查了隐性改变</li>
<li>当需求更改后,无需更改代码,删除BaseLine图像即可。
<h3>1、安装</h3>
<p><strong>使用cypress-plugin-snapshots插件进行可视化测试</strong></p>
<pre><code>npm i cypress-plugin-snapshots -S</code></pre>
<h3>2、更改cypress.json文件</h3>
<p>在cypress.json文件中添加:</p>
<pre><code>"ignoreTestFiles": [
"**/__snapshots__/*",
"**/__image_snapshots__/*"
]</code></pre>
<h3>3、 更改plugin文件夹下的index文件</h3>
<pre><code>const { initPlugin } = require('cypress-plugin-snapshots/plugin');
module.exports = (on, config) => {
initPlugin(on, config);
return config;
};</code></pre>
<h3>4、 更改support文件夹下的index.js文件</h3>
<pre><code>const { initPlugin } = require('cypress-plugin-snapshots/plugin');
module.exports = (on, config) => {
initPlugin(on, config);
return config;
};</code></pre></li>
</ol>
<h1>参考</h1>
<p>[1]. <a href="https://github.com/meinaart/cypress-plugin-snapshots">cypress-plugin-snapshots官方文档</a></p>