WordPress / theme-review-action

Other
30 stars 9 forks source link

Halt tests if connection is refused #38

Open carolinan opened 3 years ago

carolinan commented 3 years ago

I tested npm install inside the ui-check folder and there were no issues. Then I used npm start and it runs the tests but the connection is refused:

net::ERR_CONNECTION_REFUSED at http://localhost:8889/?feed=rss2

When the connection is refused, I don't think there is any point in continuing with the next test? I mean that the tests could stop at this error.

StevenDufresne commented 3 years ago

Calling the UI-check directly in the folder is still somewhat problematic because, currently, the tests expect that wp-env configured the environment. After the environment is complete, there are a series of environment configurations that run. Not having those will trigger multiple test failures if manual configurations are not done the same.

Additionally, the project shouldn't get that far if it's run from the top level since it suggests that there is nothing running http://localhost:8889/?feed=rss2 (unless there was another reason for this error), meaning the environment install didn't work and the tests wouldn't work.

Now, if you are adventurous, you can pass in a local port via an environment variable if you still want to test and don't have a local environment configured on port 8889.

https://github.com/WordPress/theme-review-action/blob/15f89b51ada1036aaff1b9f4f928d1281b7850f4/actions/ui-check/tests/utils/environment.js#L3

You can try something like: WP_ENV_TESTS_PORT=3000 npm run start.