Skip to content
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

composer test:plugins failed with error #1256

Closed
mukeshpanchal27 opened this issue May 29, 2024 · 5 comments · Fixed by #1314
Closed

composer test:plugins failed with error #1256

mukeshpanchal27 opened this issue May 29, 2024 · 5 comments · Fixed by #1314
Labels
Infrastructure Issues for the overall performance plugin infrastructure [Type] Bug An existing feature is broken

Comments

@mukeshpanchal27
Copy link
Member

Bug Description

Run composer test:plugins command.

> phpunit '--verbose' '--testsuite' 'auto-sizes'
Error: The following required constants are not defined: WP_TESTS_DOMAIN, WP_TESTS_EMAIL, WP_TESTS_TITLE, WP_PHP_BINARY.
Please check out `wp-tests-config-sample.php` for an example.
Script phpunit handling the test event returned with error code 1
Script @test --verbose --testsuite auto-sizes was called via test:auto-sizes
Script @test:auto-sizes was called via test:plugins

Screenshots

Screenshot 2024-05-29 at 10 57 27 AM
@mukeshpanchal27 mukeshpanchal27 added [Type] Bug An existing feature is broken Infrastructure Issues for the overall performance plugin infrastructure labels May 29, 2024
@westonruter
Copy link
Member

You can't run that command directly unless you have set up tests on your host environment. You gave to use the npm wrapper instead, AFAIK.

@mukeshpanchal27
Copy link
Member Author

Got it. But we should document this somewhere so others understand why it’s not working. What do you think?

@westonruter
Copy link
Member

Yeah, agreed. That error message should explain this, and reference the npm command to use instead. It could link to the handbook with instructions for how to set up the test environment without using wp-env as well.

@AhmarZaidi
Copy link
Contributor

Hey, I was thinking of a an approach where we can define a pretest script to run before composer test like this:

"pretest": "php pretest.php",
"test":  ["@pretest", "phpunit"],

In the pretest.php script we can check if the environment is correct and print error message accordingly.

Should I go ahead with this approach or is there a better way?

@westonruter
Copy link
Member

@AhmarZaidi that seems good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Issues for the overall performance plugin infrastructure [Type] Bug An existing feature is broken
3 participants