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

[Bug]: documentation and behaviour of mockFn.mockName(name) do not match #12850

Closed
mrazauskas opened this issue May 16, 2022 · 4 comments · Fixed by #12913
Closed

[Bug]: documentation and behaviour of mockFn.mockName(name) do not match #12850

mrazauskas opened this issue May 16, 2022 · 4 comments · Fixed by #12913

Comments

@mrazauskas
Copy link
Contributor

mrazauskas commented May 16, 2022

Version

28.1.0

Steps to reproduce

See mockFn.mockName(name) documentation. Try running the code found there. Notice that output is different than documented.

Expected behavior

Output and documentation is matching.

Actual behavior

Documentation states that this code:

const mockFn = jest.fn().mockName('mockedFunction');

// mockFn();
expect(mockFn).toHaveBeenCalled();

Should print:

expect(mockedFunction).toHaveBeenCalled()

Expected mock function "mockedFunction" to have been called, but it was not called.

The actual printout is:

expect(mockedFunction).toHaveBeenCalled()

Expected number of calls: >= 1
Received number of calls:    0

Additional context

PR which changed the code #8649. Nice work. Screenshots show the difference which I described in this ticket.

So only the documentation should be updated? Looking at the whole context, it does not seems to be a regression in code. Or?

Environment

System:
    OS: macOS 12.3.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 18.0.0 - /opt/homebrew/bin/node
    Yarn: 1.22.18 - ~/.yarn/bin/yarn
    npm: 8.6.0 - /opt/homebrew/bin/npm
  npmPackages:
    jest: ^28.1.0 => 28.1.0
@github-actions
Copy link

github-actions bot commented Jul 5, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Jul 5, 2022
@github-actions github-actions bot removed the Stale label Jul 15, 2022
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Aug 14, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant