Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking API errors doesn't work in 1.20.0 #7213

Closed
sorin-davidoi opened this issue Aug 2, 2022 · 1 comment · Fixed by DevExpress/testcafe-hammerhead#2790
Closed

Mocking API errors doesn't work in 1.20.0 #7213

sorin-davidoi opened this issue Aug 2, 2022 · 1 comment · Fixed by DevExpress/testcafe-hammerhead#2790
Assignees
Labels
TYPE: bug The described behavior is considered as wrong (bug).

Comments

@sorin-davidoi
Copy link

sorin-davidoi commented Aug 2, 2022

What is your Scenario?

Use RequestMock to mock API errors (status code != 200).

What is the Current behavior?

TestCafe throws An unhandled error occurred in the "onResponse" method of the "RequestMock" class: null.

What is the Expected behavior?

The request should be mocked and no error thrown. This used to work in 1.19.0.

What is your public website URL? (or attach your complete example)

https://testcafe.io

What is your TestCafe test code?

import { RequestMock, t } from 'testcafe';

fixture`Demo`;

test
    .page('https://testcafe.io')
    .requestHooks(
        RequestMock()
            .onRequestTo(/d/)
            .respond('', 500)
    )
    ('should pass', async () => {
        await t.wait(1000);
    });

Your complete test report

Demo
 ✖ should pass

   1) An unhandled error occurred in the "onResponse" method of the "RequestMock" class:
      
      null

      Browser: Firefox 102.0 / Linux 0.0

Steps to Reproduce

  1. Install testcafe@1.20.0
  2. Run testcafe firefox:headless test.ts, observe failure
  3. Run with testcafe@1.19.0, observe that the test passes

TestCafe version

1.20.0

Node.js version

v16.14.0

Command-line arguments

testcafe firefox:headless test.ts

Browser name(s) and version(s)

Firefox 102

Platform(s) and version(s)

Fedora 36

Other

Works in 1.19.0.

@sorin-davidoi sorin-davidoi added the TYPE: bug The described behavior is considered as wrong (bug). label Aug 2, 2022
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Aug 2, 2022
@Aleksey28
Copy link
Collaborator

Hi @sorin-davidoi,

I reproduced the issue. We will update this thread once we have news.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants