lib: refactor lazy loading of undici for fetch method · nodejs/node@fdcde84 · GitHub
Skip to content

Commit fdcde84

Browse files
Victor Chenaduh95
authored andcommitted
lib: refactor lazy loading of undici for fetch method
Object.defineProperty is updated to lazily load the undici dependency for the fetch method. This change allows for simpler and more reliable mocking of the fetch method for testing purposes, resolving issues encountered with premature method invocation during testing. Fixes: #52015 PR-URL: #52275 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent f6145aa commit fdcde84

2 files changed

Lines changed: 35 additions & 26 deletions

File tree

lib/internal/bootstrap/web/exposed-window-or-worker.js

Lines changed: 15 additions & 26 deletions

test/parallel/test-fetch-mock.js

Lines changed: 20 additions & 0 deletions

0 commit comments

Comments
 (0)