bigbite / wp-cypress

WordPress end to end testing with Cypress.io.
MIT License
86 stars 19 forks source link

PHP Memory limit exceeded during initialisation #130

Open g-elwell opened 11 months ago

g-elwell commented 11 months ago

Describe the bug When starting WP Cypress on a project with a lot of plugins, I have hit an issue where the PHP memory limit is exceeded, resulting in the CLI process exiting.

This appears to occur despite configuring the PHP memory limit to a higher level in cypress.config.js, ref #78.

Tracing the issue back, it appears that the memory limit of 64M defined in php.ini, is being utilised for some time prior to the memory limit defined in the config.

Therefore, increasing the memory limit in the config has no impact in some situations, although it may resolve other issues where memory is exhausted later in the process.

Also related #54

To Reproduce This may be difficult to replicate as the specific combination of plugins in use on your project will all contribute to the memory being used.

Steps to reproduce the behavior:

  1. Create a project with many active plugins
  2. Run WP Cypress npx wp-cypress start
  3. Expect to see the PHP memory limit issue
  4. Increase PHP memory limit in cypress.config.js ref #78
  5. Run WP Cypress npx wp-cypress start
  6. Expect to see the same PHP memory limit issue

To work around this we can:

  1. Add configFile: '/wp-cypress-config.php' to wp config in cypress.config.js
  2. Create wp-cypress.config.php with <?php ini_set('memory_limit','256M');
  3. Re-run WP Cypress
  4. Notice the memory limit has increased and initialisation issue is not hit

Expected behavior When the PHP memory limit is increased, this should raise the limit during initialisation too.

Desktop (please complete the following information):