datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 50 forks source link

test: chdir before importing anything from gatsby so main and child processes have shared cwd #208

Closed pieh closed 1 year ago

pieh commented 1 year ago

Gatsby removed conditional code paths for feature flags that were enabled by default (when running actual gatsby commands) in https://github.com/gatsbyjs/gatsby/pull/36810

This means that test setup for this plugin was actually not using PQR mode when testing against v4 and earlier and falled back to single process query running, but that changed in v5 and now there is no way not to run in PQR mode. This adjusts the test helper setup so that process.cwd() is the same for "main process" and PQR workers by setting it up before any of Gatsby imports (some of gatsby modules would init variables using process.cwd() and that includes cache that is used by this plugin to share data between processes