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

lib: refactor lazy loading of undici for fetch method #52275

Merged

Commits on Apr 7, 2024

  1. 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: nodejs#52015
    YCChenVictor committed Apr 7, 2024
    Configuration menu
    Copy the full SHA
    3fdd4d3 View commit details
    Browse the repository at this point in the history

Commits on Apr 9, 2024

  1. lib: implement lazy loading for fetch function

    Instead of importing undici upfront, the module is now conditionally
    required using require only when the fetch function is called for the
    first time and the undici implementation is not already available. This
    lazy loading approach improves resource usage and test reliability by
    loading undici only when needed.
    YCChenVictor committed Apr 9, 2024
    Configuration menu
    Copy the full SHA
    5c6a889 View commit details
    Browse the repository at this point in the history

Commits on Apr 11, 2024

  1. lib: test for fetch mock without prior invocation

    The purpose of this test is to verify the correct behavior of stubbing
    the globalThis.fetch method with custom implementation. It checks
    whether the stubbed fetch function correctly returns the expected
    response without calling fetch iteself first.
    YCChenVictor committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    7937b69 View commit details
    Browse the repository at this point in the history