Bug
The request was intercepted, but returns 222 "unknown" on status code even with respond(null, 500).
Request need to return status 500 after call.
Test code
I used a jsonplaceholder to test once the final API URL can't be shared, but it's the same idea and got the same problem.
const mock = RequestMock()
.onRequestTo('https://jsonplaceholder.typicode.com/posts/1')
.respond(null, 500);
fixture`Summary account errors`.requestHooks(mock);
test('Error scenario: request with status code 500', async t =>
await t
.navigateTo(PAGE_URL)
.debug());
Hi @salesgu
Thank you for your report.
Your test page performs a cross-domain ajax request to the mocked url. The mocked url should pass a CORS validation. 222 is an internal status code that means request failed the CORS validation.
You should to modify your code as follows:
const mock = RequestMock()
.onRequestTo('https://jsonplaceholder.typicode.com/posts/1')
.respond(null, 500, {'access-control-allow-origin': '*'});
Also I've added a clear warning message for this case - https://github.com/DevExpress/testcafe/commit/3cd7b7d61359a6200e8204534b1a3d25ba6c5435
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.
Most helpful comment
Hi @salesgu
Thank you for your report.
Your test page performs a cross-domain ajax request to the mocked url. The mocked url should pass a CORS validation.
222is an internal status code that means request failed the CORS validation.You should to modify your code as follows:
Also I've added a clear warning message for this case - https://github.com/DevExpress/testcafe/commit/3cd7b7d61359a6200e8204534b1a3d25ba6c5435