PHPUnit Ajax Serialization of ‘Closure’ is not allowed

Figured out that it was the @runTestsInSeparateProcesses annotation in the test class that was causing the error. Not sure why that would cause it. Once I removed it, the test completed successfully.

./vendor/bin/phpunit --group ajax
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 9.5.24 #StandWithUkraine

.                                                                   1 / 1 (100%)

Time: 00:00.008, Memory: 32.00 MB

OK (1 test, 1 assertion)