-
Notifications
You must be signed in to change notification settings - Fork 4.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
Provide unit testing devDependencies from wp-scripts #17016
Comments
Yes, I opened to WordPress/gutenberg-examples#84 to investigate further and I wasn't happy about the result. There are a few things that might go smoother so overall I consider it as a bug as it might be painful to write a single test with linting enabled :)
WordPress/gutenberg-examples#84 (comment)
WordPress/gutenberg-examples#84 (review)
|
I started #17027 and I think I will be able to fix all the issue. |
This might need to be a different issue, but it'd be awesome to also provide all of the I tried just adding |
Er,
|
Er, part of my problem above was that I was accidentally importing It does seem like there's still a need to import things like |
Shouldn’t you put them as regular dependencies? If you are testing them, I would assume that you are using them in your codebase as well. In fact, I double checked the link you shared and it looks like all dependencies which I see in the components aren’t properly installed in package.json file: This might be confusing a bit but everything you import in the code that gets shipped to the user should be added to regular (aka production) dependencies section. This is expected strategy when working with npm. We convert all the dependencies which WordPress uses to wp globals so but for unit tests we need sources of those packages. Honestly, I don’t know what would be the best strategy here. If you want to explore it further let’s open new issue and use The weekly Core JS chat to gather more feedback. In the meantime, at least @wordpress/element will get installed by default as a deep dependency of the package when we publish the next version of @wordpress/scripts. |
I’ll open a new issue early next week which will propose some better handling for component testing which installs react-test-renderer behind the scenes. |
They're not being used directly in any custom code, but they're dependencies of things the custom code imports. Part of the difference in expectations may be that I'm using |
Okay, I see them listed as dev dependencies here: However, I also see them used in the actual code: So my previous statement still holds, they should be listed as regular dependencies even though you technically don't need them to build your plugin when using |
Ah, you're right, most of them are being used. I think I've found two that aren't though: |
I think you had to add them because we had tons of configuration issues in the list of dependencies. I fixed all (hopefully) of them in #16969. I see I added both dependencies you listed in this PR. We need another release of packages and I hope this won't be an issue anymore after you bump versions of WordPress dependencies. I should perform the npm release tomorrow if the next version of Gutenberg is successfully released today. |
These aren't needed to run the code, because they exist in the `wp` namespace as externals, but they are needed for unit tests, since they don't otherwise exist in that context. See WordPress/gutenberg#17016 (comment).
These aren't needed to run the code, because they exist in the `wp` namespace as externals, but they are needed for unit tests, since they don't otherwise exist in that context. See WordPress/gutenberg#17016 (comment).
These aren't needed to run the code, because they exist in the `wp` namespace as externals, but they are needed for unit tests, since they don't otherwise exist in that context. See WordPress/gutenberg#17016 (comment).
These aren't needed to run the code, because they exist in the `wp` namespace as externals, but they are needed for unit tests, since they don't otherwise exist in that context. See WordPress/gutenberg#17016 (comment).
These aren't needed to run the code, because they exist in the `wp` namespace as externals, but they are needed for unit tests, since they don't otherwise exist in that context. See WordPress/gutenberg#17016 (comment).
Problem
wp-scripts
provides some of the framework necessary to unit-test plugins, but not all. One specific piece that's missing is many of the dev-dependencies still need to be added to the plugin'spackage.json
. For example, https://github.com/WordPress/wordcamp.org/pull/211/files.Proposed Solution
Those dependencies (and any others) should be added to
wp-scripts
'spackage.json
, so that plugins inherit them automatically.cc @gziolo , who I think is planning to work on some related issues.
The text was updated successfully, but these errors were encountered: