Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rules/__tests__/unbound-method.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const validTestCases: string[] = [
'expect(Console.prototype.log).toHaveBeenCalledTimes(1);',
'expect(Console.prototype.log).not.toHaveBeenCalled();',
'expect(Console.prototype.log).toStrictEqual(somethingElse);',
'jest.mocked(Console.prototype.log).mockImplementation(() => {});',
].map(code => [ConsoleClassAndVariableCode, code].join('\n')),
dedent`
expect(() => {
Expand Down
10 changes: 10 additions & 0 deletions src/rules/unbound-method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ export default createRule<Options, MessageIds>({
...baseSelectors,
MemberExpression(node: TSESTree.MemberExpression): void {
if (node.parent?.type === AST_NODE_TYPES.CallExpression) {
if (
node.parent.callee.type === AST_NODE_TYPES.MemberExpression &&
node.parent.callee.object.type === AST_NODE_TYPES.Identifier &&
node.parent.callee.object.name === 'jest' &&
node.parent.callee.property.type === AST_NODE_TYPES.Identifier &&
node.parent.callee.property.name === 'mocked'
) {
return;
}

const jestFnCall = parseJestFnCall(
findTopMostCallExpression(node.parent),
context,
Expand Down
Loading