Skip to content

Commit

Permalink
fix: error doesn't handle in the respond of the RequestMock (#7112)
Browse files Browse the repository at this point in the history
* initial

* update hammerhead

* remove dev artifacts
  • Loading branch information
miherlosev committed Jun 28, 2022
1 parent dad74b3 commit 549aed9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"source-map-support": "^0.5.16",
"strip-bom": "^2.0.0",
"testcafe-browser-tools": "2.0.23",
"testcafe-hammerhead": "24.5.22",
"testcafe-hammerhead": "24.5.23",
"testcafe-legacy-api": "5.1.4",
"testcafe-reporter-dashboard": "1.0.0-rc.3",
"testcafe-reporter-json": "^2.1.0",
Expand Down
8 changes: 8 additions & 0 deletions test/functional/fixtures/api/es-next/request-hooks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ describe('Request Hooks', () => {
it('Asynchronous response function (GH-4467)', () => {
return runTests('./testcafe-fixtures/request-mock/async-response-function.js', null, { only: 'chrome' });
});

it("Handle error in 'respond' function (GH-6703)", () => {
return runTests('./testcafe-fixtures/request-mock/respond-error.js', null, { only: 'chrome', shouldFail: true })
.catch(() => {
expect(testReport.errs.length).eql(1);
expect(testReport.errs[0]).contains('Error in the "respond" method');
});
});
});

describe('RequestLogger', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { RequestMock } from 'testcafe';

const mock = RequestMock()
.onRequestTo('http://dummy-url.com/get')
.respond(() => {
throw new Error('Error in the "respond" method');
});

fixture `Fixture`
.requestHooks(mock);

test('test', async t => {
await t.navigateTo('http://dummy-url.com/get');
});

0 comments on commit 549aed9

Please sign in to comment.