使用cypress.io进行测试时,有没有一种方法可以断言没有对给定的URL发出XHR请求?
我想声明在单击"保存"按钮时添加了新的foo,但是在单击"取消"按钮时则没有.
像这样的东西:
cy.route('POST', '/foos').as('postFoo');
cy.get('.cancel-button').click();
cy.route('@postFoo').should('not.have.been.called'); // (magic imaginary syntax!)
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用执行assert.fail的onRequest回调设置cy.route,但是当调用URL时,这并没有使测试失败.
现在,我正在捕捉我的(故意)"没有请求发生"错误,如下所示:
cy.on('fail', (err, runnable) => {
expect(err.message).to.include('No request ever occurred.');
return false;
});
cy.wait('@postFoo', { timeout: 0 }).then(xhr => {
throw new Error('Unexpected API call.');
});
Run Code Online (Sandbox Code Playgroud)
...这似乎有效,但它肯定不会感到非常"cypress-y".
我收到此System.ServiceModel.FaultException通过WCF从我的.NET应用程序调用SAP XI/PI Web服务:
CX_SY_CONVERSION_NO_DATE_TIME:XSLT异常.在简单转换程序中反序列化时发生错误/1BCDWB/WSSB430AA018B4EA689BF0.Value 7/12/2010不是符合ABAP XML格式的有效日期
有问题的日期是我使用.NET DateTime.ToShortDateString()方法格式化的字符串字段.
谁能告诉我有效的"ABAP XML格式"是什么日期?