You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature a mock’s name more prominently in a test failure.
Motivation
I love that you've added the ability to be able to name mocks but, in order to make the output error messages easier to read and understand I propose including a mock’s name in the error message.
Rather than Expected mock function to have been called.
Something like Expected the mock function 'myMockedFunction' to have been called..
Now I recognise that currently you include expect(myMockedFunction).toBeCalled() on the line above but I must admit, personally, because it's in grey I assume it isn't the most important information in the error message.
Am happy do submit a PR if you want.
Example
Given this short example
test('should show the name of the mock in the test',()=>{constfn=jest.fn().mockName('myMockedFunction');expect(fn).toBeCalled();});
this currently fails with:
● should show the name of the mock in the test
expect(myMockedFunction).toBeCalled()
Expected mock function to have been called.
2 | const fn = jest.fn().mockName('myMockedFunction');
3 |
> 4 | expect(fn).toBeCalled();
5 | });
I propose it failing with
● should show the name of the mock in the test
expect(myMockedFunction).toBeCalled()
Expected mock function 'myMockedFunction' to have been called.
2 | const fn = jest.fn().mockName('myMockedFunction');
3 |
> 4 | expect(fn).toBeCalled();
5 | });
Pitch
Because the improvement exists in the expect module which is part of the core package.
The text was updated successfully, but these errors were encountered:
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.
🚀 Feature Proposal
Feature a mock’s name more prominently in a test failure.
Motivation
I love that you've added the ability to be able to name mocks but, in order to make the output error messages easier to read and understand I propose including a mock’s name in the error message.
Rather than
Expected mock function to have been called.
Something like
Expected the mock function 'myMockedFunction' to have been called.
.Now I recognise that currently you include
expect(myMockedFunction).toBeCalled()
on the line above but I must admit, personally, because it's in grey I assume it isn't the most important information in the error message.Am happy do submit a PR if you want.
Example
Given this short example
this currently fails with:
I propose it failing with
Pitch
Because the improvement exists in the expect module which is part of the core package.
The text was updated successfully, but these errors were encountered: