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

[Feature]: Chain nthCalledWith #13646

Closed
paullewisn opened this issue Nov 29, 2022 · 3 comments
Closed

[Feature]: Chain nthCalledWith #13646

paullewisn opened this issue Nov 29, 2022 · 3 comments

Comments

@paullewisn
Copy link

paullewisn commented Nov 29, 2022

🚀 Feature Proposal

When using nthCalledWith, but expecting no arguments, the code does not read intuitively for those who are not familiar with this Jest matcher. I think the wording should be updated, or better still the ability to chain the command.

Motivation

Generally, Jest code is very declarative and can be read by those with no understanding of the framework. It could even be easily understood by those with little technical skill. This matcher, called in this circumstance is harder to understand.

Example

No response

Pitch

> foo.js
...
    bar();
    bar("foo");
....

Current method:

...
    expect(bar).nthCalledWith(1); //novice PR reviewer: "but bar isn't called with 1"
    expect(bar).nthCalledWith(2, "foo"); //this context makes it obvious
...

Proposed change:

...
    expect(bar).toBeNth(1).calledWith();
    expect(bar).toBeNth(2).calledWith("foo");
...

I have tried to make the wording read similar to .toBeCalledWith, .toBe etc

EDIT +1hr
On second thoughts, perhaps expect(bar).nthCalledWith(1, expect.nothing) would work too.

@feliperli
Copy link
Contributor

Hey! I'm picking up this issue :) I'll mention you when I have a PR

@SimenB
Copy link
Member

SimenB commented Jan 3, 2023

#13675 (comment)

@SimenB SimenB closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2023
@github-actions
Copy link

github-actions bot commented Feb 3, 2023

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 Feb 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants