WordPress/gutenberg

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

Open

#17 273 ouverte le 30 août 2019

Voir sur GitHub
 (9 commentaires) (1 réaction) (0 assignés)JavaScript (3 893 forks)batch import
Good First IssueNeeds Dev[Status] In Progress[Type] Automated Testing[Type] Enhancementnpm Packages

Métriques du dépôt

Stars
 (9 607 stars)
Métriques de merge PR
 (Merge moyen 12j 18h) (509 PRs mergées en 30 j)

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 https://github.com/WordPress/gutenberg/pull/17165#issuecomment-525193133:

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.

Guide contributeur