-
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
(5P) SPT add JS Functional tests to the plugin #35379
Conversation
@getdave You're adding 12k lines of code? :) |
Wowzers. Why is |
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
Did we commit the package.lock? The dependencies in package.json can likely be removed in a janiortorial all of our dependencies are externalized |
a41405b
to
7bea67a
Compare
7bea67a
to
26e2cf3
Compare
Note that we're removing the |
afc1745
to
9c3e5c0
Compare
…stead This is required because of the Calypso monorepo relying on root dependencies. We don’t want to install @wordpress/scripts in Calypso root so npx is the best interim soluton. See #35379 (comment)
When I remove
@sirreal I'm going to install |
I've refactored to use React Testing Library because Enzyme is being "deprecated" by Gutenberg Core |
…stead This is required because of the Calypso monorepo relying on root dependencies. We don’t want to install @wordpress/scripts in Calypso root so npx is the best interim soluton. See #35379 (comment)
2221ee1
to
01a5d35
Compare
Given this is operating as a fairly isolated project, and I don't think there's a good way around that now, no problem from me 👍 |
…stead This is required because of the Calypso monorepo relying on root dependencies. We don’t want to install @wordpress/scripts in Calypso root so npx is the best interim soluton. See #35379 (comment)
…encies and causes test runner errors
…Gutenberg Core Rewrote tests using RTL and it is much nicer and avoids testing implementation details. I have much more confident in my tests.
@wordpress/jest-preset-default is required in order to extend the @wordpress/scripts jest config
01a5d35
to
6589029
Compare
Exists as a pass through component to simplying testing components which consume `BlockPreview` from `@wordpress/block-editor`. This is because jest cannot mock node modules that are not part of the root node modules. Due to the way this projects dependencies are defined `@wordpress/block-editor` does not exist within `node_modules` and it is there impossible to mock it without providing a wrapping component to act as a pass though. See https://jestjs.io/docs/en/manual-mocks
Previously adding conditionals in tests had removed the ability to provide a “blank” value in the Templates. Now add this as an explicit assertion across multiple tests to ensure it isn’t lost again.
...iting-plugin/starter-page-templates/page-template-modal/components/template-selector-item.js
Show resolved
Hide resolved
...starter-page-templates/page-template-modal/components/test/template-selector-control-test.js
Show resolved
Hide resolved
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 inline comments @getdave, that made it easier to follow what your thought process behind certain decisions was e.g. the pass-through component. Testing it locally, the tests are passing as expected. With the comments and existing discussions in mind, nothing immediately jumps out to me right now. Given that it shouldn't affect Calypso but just our plugin, I'd be OK with getting this in and continue iterating from there 👍
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.
The changes purposed here don’t affect the current functionality of the plugin, and the tester framework looks pretty good.
I suggest 🚢 this tool since it will helpful for our development flow, considering that we can rollback if we find out another testing approach.
Thanks for taking over of this task, Dave.
Thanks @retrofox and @frontdevde. Appreciate your feedback and 👍 on this PR. Let's hope it helps us 🚢 with greater confidence. |
Whilst it is important to test for the presence of `blocks` it does not hurt to provide a default value as this ensures the “blank” state can be provided when in dynamic mode.
This PR aims to add a JS unit test framework to the SPT Plugin via
@wordpress/scripts
.However, as Gutenberg Core is considering dropping Enzyme the tests are written in React Testing Library. There is also a custom Jest config to allow us to overide the default settings for our Plugin as required.
All components are now covered by a test. Note that some components do not have their own individual test because they are covered by the parent component as we no longer use
shallow
rendering.Please note
devDependencies
have been introduced. These are entirely necessary and have been agreed with @sirreal (see comments below) as being valid.package-lock.json
and@wordpress/scripts
dependency. Don't panic.Testing instructions
npm install
within theapps/full-site-editing
dirapps/full-site-editing
dirnpm run test:unit:watch