Update Documentation to Include undici Compatibility Issues and Solutions
Scope
Improves an existing behavior
Compatibility
- [ ] This is a breaking change
Feature description
Description
After updating undici from version 6.15.0 to 6.16.0, compatibility issues arose in our testing environment that utilizes jsdom and msw for network request mocking. Specifically, the errors involve markResourceTiming not being a function and issues accessing the location property on Window. These errors cause our unit tests to fail. A solution involving the manual addition of these properties to the global object has been identified and tested successfully.
Documentation Update Suggestion
The current Migration Guide from 1.x to 2.x could be expanded to include guidance on handling compatibility issues with undici and jsdom. It would be beneficial for users facing similar issues if the documentation could outline steps to manually add necessary properties to the global object in testing environments using msw and undici.
Proposed Changes
- Add a new section under the existing migration guide or in a relevant part of the documentation.
- Include an explanation of the potential errors when using
undiciwithmswandjsdom. - Provide code snippets like the following for quick fixes:
globalThis.performance.markResourceTiming = () => {}; // Additional properties might be needed depending on the specific errors encountered.
This documentation update would help prevent future issues for users upgrading undici in a similar setup and enhance the usability of msw in complex JavaScript testing environments.
References
GitHub issue in nodejs/undici discussing the problem: undici#3237