Hoa*_*Son 5 e2e-testing angular cypress angular7
我正在尝试使用 Cypress 和cypress-plugin-snapshots在我的页面上进行 e2e 测试的快照测试。
但我得到了这个错误TypeError: cy.document(...).toMatchSnapshot is not a function。
这是我的配置:
插件/index.js
const { initPlugin } = require('cypress-plugin-snapshots/plugin');
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
initPlugin(on, config);
return config;
}
Run Code Online (Sandbox Code Playgroud)
支持/index.js
import 'cypress-plugin-snapshots/src/commands';
Run Code Online (Sandbox Code Playgroud)
赛普拉斯.json
{
"ignoreTestFiles": [
"**/__snapshots__/*",
"**/__image_snapshots__/*"
]
}
Run Code Online (Sandbox Code Playgroud)
home.spec.js
context('Querying', () => {
beforeEach(() => {
cy.server();
cy.fixture('user.json').as('userJSON');
cy.route('GET', 'users?id=*', '@userJSON').as('getUser');
cy.visit('http://localhost:4200/1');
})
it.only('LANDING - Snapshot test', () => {
cy.wait(['@getUser']);
cy.document().toMatchSnapshot()
});
})
Run Code Online (Sandbox Code Playgroud)
刚刚有同样的问题。你的代码应该是:
expect(cy.document()).toMatchSnapshot()
Run Code Online (Sandbox Code Playgroud)
请注意expect
| 归档时间: |
|
| 查看次数: |
3065 次 |
| 最近记录: |