Add php unit watcher and update unit test docs #44681
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Submission Review Guidelines:
Changes proposed in this Pull Request:
When writing unit tests, it's often necessary to run them multiple times to ensure they pass correctly.
In JavaScript, Jest offers a
--watch
mode, which monitors file changes and automatically runs tests. This feature proves invaluable during JS development and test writing.This PR introduces the addition of the phpunit-watcher package to the
composer.json
file and commands to thepackage.json
file. These additions enable tests to rerun automatically when files are modified. The woocommerce-payments repository has successfully utilized this package for some time.Furthermore, this PR updates the unit test documentation to mandate the usage of the watcher and provides instructions for setting up the test environment using wp-env.
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Please note that, unlike Jest,
phpunit-watcher
is unable to automatically only rerun the tests that are affected by the changes. It reruns all the tests. This is a limitation of the package. I also noticed that it's a bit slow when typing in the terminal in interactive mode but it still works fine when you press enter.Screen.Recording.2024-02-16.at.15.31.22.mov
Changelog entry
Significance
Type
Message
Add php unit watcher and update unit test docs
Comment