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

Jest doesn't mock properties inherited from the last object in the prototype chain #6994

Closed
rubennorte opened this issue Sep 18, 2018 · 2 comments · Fixed by #7003
Closed

Comments

@rubennorte
Copy link
Contributor

🐛 Bug Report

Jest doesn't mock the properties in the last component of the prototype chain (even if it's not Object).

To Reproduce

Steps to reproduce the behavior:

const jestMock = require('jest-mock');

const Foo = Object.assign(Object.create(null), { foo() {} });
const Bar = Object.assign(Object.create(Foo), { bar() {} });

const BarMock = jestMock.generateFromMetadata(jestMock.getMetadata(Bar));
typeof BarMock.foo; // 'undefined'
typeof BarMock.bar; // 'function'

Expected behavior

const jestMock = require('jest-mock');

const Foo = Object.assign(Object.create(null), { foo() {} });
const Bar = Object.assign(Object.create(Foo), { bar() {} });

const BarMock = jestMock.generateFromMetadata(jestMock.getMetadata(Bar));
typeof BarMock.foo; // 'function'
typeof BarMock.bar; // 'function'
@rubennorte
Copy link
Contributor Author

I'll fix this in the same PR I'll fix #6995

@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 May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant