-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
test_runner: fix mock.method to support class instances #45608
test_runner: fix mock.method to support class instances #45608
Conversation
I haven't removed those labels, so I added them manually. Not sure if that's a problem |
2442f87
to
f076bf2
Compare
/cc @nodejs/test_runner |
66939bc
to
45b3bd4
Compare
It fixes a problem when trying to spy a method from a class instance or static functions on a class instance
Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
Signed-off-by: Erick Wendel <erick.workspace@gmail.com>
Signed-off-by: Erick Wendel <erick.workspace@gmail.com>
Commit Queue failed- Loading data for nodejs/node/pull/45608 ✔ Done loading data for nodejs/node/pull/45608 ----------------------------------- PR info ------------------------------------ Title test_runner: fix mock.method to support class instances (#45608) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch ErickWendel:test/test-mock-on-classes -> nodejs:main Labels needs-ci, dont-land-on-v14.x, test_runner Commits 19 - test: fix mock.method to support class instances - added suggestions - test: remove unecessarly if - test: drop comments and rename tests - test_runner: ensure that mock.method works with class inheritance - test: ensure that the original object was reseted after execution - test_runner: added aduh95's suggestion to extend null - test_runner: remote proto.name validation on mock - test: fix lint - test_runner: added cjihrig suggestions to turn fns private - test_runner: validate properties in objects - test_runner: add colin's suggestion to simplify algorithm on mock - test_runner: turn fn into inline if - test_runner: when method doesnt exists it shows a message - add aduh95 suggestion test/parallel/test-runner-mocking.js - test: assert by code instead of regex string - test_runner: rename object - test_runner: add test case to check prototype chain - test: assert property descriptors Committers 2 - Erick Wendel - GitHub PR-URL: https://github.com/nodejs/node/pull/45608 Reviewed-By: Colin Ihrig Reviewed-By: Yagiz Nizipli Reviewed-By: Benjamin Gruenbaum Reviewed-By: Antoine du Hamel ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/45608 Reviewed-By: Colin Ihrig Reviewed-By: Yagiz Nizipli Reviewed-By: Benjamin Gruenbaum Reviewed-By: Antoine du Hamel -------------------------------------------------------------------------------- ℹ This PR was created on Thu, 24 Nov 2022 15:50:52 GMT ✔ Approvals: 4 ✔ - Colin Ihrig (@cjihrig) (TSC): https://github.com/nodejs/node/pull/45608#pullrequestreview-1208727810 ✔ - Yagiz Nizipli (@anonrig): https://github.com/nodejs/node/pull/45608#pullrequestreview-1210162552 ✔ - Benjamin Gruenbaum (@benjamingr): https://github.com/nodejs/node/pull/45608#pullrequestreview-1218042726 ✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/45608#pullrequestreview-1221781107 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2022-12-16T23:05:30Z: https://ci.nodejs.org/job/node-test-pull-request/48536/ - Querying data for job/node-test-pull-request/48536/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 45608 From https://github.com/nodejs/node * branch refs/pull/45608/merge -> FETCH_HEAD ✔ Fetched commits as 8467aa2189ba..152539d4ac32 -------------------------------------------------------------------------------- Auto-merging lib/internal/test_runner/mock.js Auto-merging test/parallel/test-runner-mocking.js [main 8001bd86a3] test: fix mock.method to support class instances Author: Erick Wendel Date: Thu Nov 24 12:40:41 2022 -0300 2 files changed, 91 insertions(+), 9 deletions(-) Auto-merging lib/internal/test_runner/mock.js [main 424c586b99] added suggestions Author: Erick Wendel Date: Thu Nov 24 13:06:15 2022 -0300 1 file changed, 1 insertion(+), 1 deletion(-) Auto-merging lib/internal/test_runner/mock.js [main f38c70538c] test: remove unecessarly if Author: Erick Wendel Date: Thu Nov 24 13:07:30 2022 -0300 1 file changed, 2 insertions(+), 4 deletions(-) Auto-merging lib/internal/test_runner/mock.js Auto-merging test/parallel/test-runner-mocking.js [main 8b64907e9b] test: drop comments and rename tests Author: Erick Wendel Date: Wed Nov 30 14:35:19 2022 -0300 2 files changed, 3 insertions(+), 3 deletions(-) Auto-merging lib/internal/test_runner/mock.js Auto-merging test/parallel/test-runner-mocking.js [main 135db2319d] test_runner: ensure that mock.method works with class inheritance Author: Erick Wendel Date: Wed Nov 30 16:09:01 2022 -0300 2 files changed, 61 insertions(+), 9 deletions(-) Auto-merging test/parallel/test-runner-mocking.js [main e9f77ae6a5] test: ensure that the original object was reseted after execution Author: Erick Wendel Date: Wed Nov 30 16:48:21 2022 -0300 1 file changed, 3 insertions(+) Auto-merging test/parallel/test-runner-mocking.js [main 7925ccab4f] test_runner: added aduh95's suggestion to extend null Author: Erick Wendel Date: Tue Dec 6 16:47:38 2022 -0300 1 file changed, 3 insertions(+), 1 deletion(-) Auto-merging lib/internal/test_runner/mock.js [main fa9ff865b3] test_runner: remote proto.name validation on mock Author: Erick Wendel Date: Tue Dec 6 16:56:33 2022 -0300 1 file changed, 2 insertions(+), 1 deletion(-) Auto-merging test/parallel/test-runner-mocking.js [main ca940b4ceb] test: fix lint Author: Erick Wendel Date: Tue Dec 6 16:57:25 2022 -0300 1 file changed, 1 insertion(+), 2 deletions(-) Auto-merging lib/internal/test_runner/mock.js [main 1a379f41b3] test_runner: added cjihrig suggestions to turn fns private Author: Erick Wendel Date: Tue Dec 6 17:09:17 2022 -0300 1 file changed, 34 insertions(+), 33 deletions(-) Auto-merging lib/internal/test_runner/mock.js Auto-merging test/parallel/test-runner-mocking.js [main b492956cec] test_runner: validate properties in objects Author: Erick Wendel Date: Tue Dec 6 18:05:47 2022 -0300 3 files changed, 29 insertions(+), 1 deletion(-) Auto-merging lib/internal/test_runner/mock.js [main adeaffce4c] test_runner: add colin's suggestion to simplify algorithm on mock Author: Erick Wendel Date: Tue Dec 6 18:19:47 2022 -0300 1 file changed, 33 insertions(+), 34 deletions(-) Auto-merging lib/internal/test_runner/mock.js [main 49a10932dd] test_runner: turn fn into inline if Author: Erick Wendel Date: Wed Dec 7 13:04:50 2022 -0300 1 file changed, 10 insertions(+), 15 deletions(-) Auto-merging lib/internal/test_runner/mock.js Auto-merging test/parallel/test-runner-mocking.js [main 6d50eaa1f7] test_runner: when method doesnt exists it shows a message Author: Erick Wendel Date: Wed Dec 7 13:09:05 2022 -0300 3 files changed, 1 insertion(+), 22 deletions(-) Auto-merging test/parallel/test-runner-mocking.js [main f704e888b6] add aduh95 suggestion test/parallel/test-runner-mocking.js Author: Erick Wendel Date: Mon Dec 12 10:16:34 2022 -0300 1 file changed, 1 insertion(+), 1 deletion(-) Auto-merging test/parallel/test-runner-mocking.js [main b61151430b] test: assert by code instead of regex string Author: Erick Wendel Date: Mon Dec 12 10:40:37 2022 -0300 1 file changed, 1 insertion(+), 5 deletions(-) Auto-merging lib/internal/test_runner/mock.js [main 891199c137] test_runner: rename object Author: Erick Wendel Date: Mon Dec 12 11:58:58 2022 -0300 1 file changed, 6 insertions(+), 6 deletions(-) Auto-merging test/parallel/test-runner-mocking.js [main 393888c454] test_runner: add test case to check prototype chain Author: Erick Wendel Date: Tue Dec 13 12:14:38 2022 -0300 1 file changed, 25 insertions(+) Auto-merging test/parallel/test-runner-mocking.js [main f90f0591e5] test: assert property descriptors Author: Erick Wendel Date: Wed Dec 14 11:52:45 2022 -0300 1 file changed, 16 insertions(+), 6 deletions(-) ✔ Patches applied There are 19 commits in the PR. Attempting autorebase. Rebasing (2/38)https://github.com/nodejs/node/actions/runs/3719734467 |
Landed in 929aada |
It fixes a problem when trying to spy a method from a class instance or static functions on a class instance PR-URL: #45608 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
It fixes a problem when trying to spy a method from a class instance or static functions on a class instance PR-URL: nodejs#45608 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
It fixes a problem when trying to spy a method from a class instance or static functions on a class instance PR-URL: nodejs#45608 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
It fixes a problem when trying to spy a method from a class instance or static functions on a class instance PR-URL: #45608 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
It fixes a problem when trying to spy a method from a class instance or static functions on a class instance PR-URL: nodejs/node#45608 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> (cherry picked from commit 929aada39d0f418193ca03cc360ced8c5b4ce553)
It fixes a problem when trying to spy a method from a class instance or static functions on a class instance.
Working example:
and
This also makes sure that null Objects and inexisting methods are verified