Acceptance tests for cloudflare pages projects

Hi.

I am fairly new to Cloudflare pages. I love the infinite staging environments that are spun up for every commit to a pull request.

I would like to be able to trigger some acceptance tests to be automatically run as part of the checks when a new build/prelive url is generated for a pull request.

I wondered if anyone has any experience/suggestions on how to do that?

I don’t think anything exactly like what you’re trying to do exists directly within Pages today unfortunately, outside of just pushing to a specific staging branch and seeing if it builds correctly remotely.

Wrangler2 does support the wrangler pages dev command which allows you to run your Pages project locally, but it’s not a 1:1 match for production and isn’t the easiest to work with for testing. You can also of course run the same build command that you’ve set on Pages to test that, but again it won’t be a direct match for the build image yet.

I’m hopeful in the future with updates coming to the build image and things like that, we’ll be able to better replicate how things happen in production, for more reliable and replicable testing.

What kind of acceptance tests are you trying to do? Perhaps running these externally with GitHub Actions or something would be better suited? You could use an action like GitHub - WalshyDev/cf-pages-await: Wait for your Cloudflare Pages builds to finish!, wait for the Pages build, and then run your own tests against the generated URL?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.