Skip to content

Testing: Add integration test which ensures that npm packages can be used with Node #17273

Open

Description

This should prevent bugs like #17165 where a naked reference to window will crash if used in a SSR context where there's no window.

See more details in the comment from @jsnajdr #17165 (comment):

In this case, the easiest TDD-style test would be to simply import @wordpress/compose in a Node.js environment without DOM. And it would fail.

Neither compose nor components packages use the sideEffects: false flag (although they would be a good fit IMO), so using anything from compose bundles the whole library.

And the window check is a top-level statement in the module. We don't need to use or instantiate the useReducedMotion hook at all to get a broken build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Good First IssueAn issue that's suitable for someone looking to contribute for the first timeNeeds DevReady for, and needs developer efforts[Type] Automated TestingTesting infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.[Type] EnhancementA suggestion for improvement.npm PackagesRelated to npm packages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions