-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Gutenberg: include @wordpress/data package #26203
Conversation
package.json
Outdated
@@ -27,6 +27,8 @@ | |||
"@babel/preset-react": "7.0.0-beta.44", | |||
"@babel/preset-stage-2": "7.0.0-beta.44", | |||
"@babel/runtime": "7.0.0-beta.44", | |||
"@wordpress/data": "1.0.0", | |||
"ajv": "6.5.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the ajv dep?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was running into this during installation:
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
Haven't checked if it's really necessary yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok. i think that's a npm issue. we see it on master too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the additional context! As expected, removing it didn't cause any issues on this branch.
💖looks promising. Let's move over testing registerStore and dispatch into a unit test. Since Gutenberg is developing so quickly this will help let us know if anything has changed with future package updates. We can maybe remove this later once things stabilize a bit. After we verify that we haven't added bloat to other bundles (besides the gutenberg section) http://iscalypsofastyet.com/branch?branch=try/wordpress-data I think we can land this. |
CI errors are from having an empty test file:
|
@gwwar moved these and a couple of other
|
335786d
to
1810720
Compare
@@ -0,0 +1,103 @@ | |||
/** | |||
* @format | |||
* @jest-environment jsdom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do? Do we have some new ✨ automation options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gwwar Without it the test will produce this error:
ReferenceError: window is not defined
at registerReducer (node_modules/@wordpress/data/build/registry.js:215:5)
...
Quoting the testing docs:
It's very possible that your tests will assume the existence of a browser environment to work properly. The test runner we use, Jest, uses the browser-like environment jsdom. We default to a node-like environment to make tests faster. If some tests require another environment, you can add /** @jest-environment jsdom */ docblock. Check this Jest doc to learn more.
It looks like the registerReducer
depends on window
, so I had to include this to make tests happy.
const reducer = () => 'tea'; | ||
|
||
const store = registerReducer( 'reducer', reducer ); | ||
expect( store.getState() ).toEqual( 'tea' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍵
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vindl 🎉 this is good to ship after we resolve package conflicts + make sure the shrinkwrap matches.
1810720
to
a870cdb
Compare
a870cdb
to
849bfb6
Compare
Part of #26180
Set up a Calypso test branch for
@wordpress/data
package and add some basic tests for it.Testing instructions
npm run test-client client/gutenberg/editor/test/index.js