-
Notifications
You must be signed in to change notification settings - Fork 5
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
Integration tests aren't isolated #36
Comments
Pest v1 doesn't have process isolation, like regular phpunit does, so I kinda think that would be the 'culprit' here. |
Gotcha, makes sense - any chance of working towards an upgrade to pest v2? |
Until WP core updates their unit test suites to be compatible with PHPUnit 10 there's not much I can do. I've opened up a trac ticket about it, but that one will probably be closed in favor of one with much more detailed steps necessary to move it forward. |
Hey @dingo-d nice thanks for the update. I'll follow along and hopefully we'll get PHPUnit 10 compatibility in WP soon 😄 In the mean time, in case anyone else encounters this, note that I worked around my specific issue by doing something like this with my tests (this is a simplified example). beforeEach(function (){
global $wp_actions;
unset($wp_actions['my_action']);
});
test('my action fires', function (){
do_action('my_action');
expect(did_action('my_action'))->toBeTrue();
});
test('my action does not fire', function (){
expect(did_action('my_action'))->toBeFalse();
}); |
Describe your bug
When running consecutive integration tests, much of the WordPress lifecycle seem to persist between the tests. I would expect each request to run independently.
Steps to Reproduce
Here's two example tests that demonstrate the issue:
Expected behavior
The action was defined in the first test, and I would expect it to only fire in that test.
Screenshots, screen recording, code snippet
No response
Environment info
PHP 8.1
WordPress 6.4.2
Please confirm that you have searched existing issues in this repo.
Yes
The text was updated successfully, but these errors were encountered: