Add end-to-end tests to CI
twifkak opened this issue · comments
#41 runs the unit tests for Rust & TypeScript. Add to this, something that tests that they interact correctly with each other and with the Cloudflare Worker environment. Ideas:
End-to-end tests:
- Run
wrangler dev
andcurl localhost:8787 | dump-signedexchange -verify
- Deploy to a test environment: https://github.com/marketplace/actions/deploy-to-cloudflare-workers-with-wrangler
Integration tests for individual TS functions:
- Mock Cloudflare Worker environment: https://blog.cloudflare.com/unit-testing-worker-functions/
- Using
wrangler dev
: https://www.paolotagliaferri.com/test-cloudflare-workers-with-jest-wrangler-travis/ - Deploy to a test environment: https://blog.cloudflare.com/unit-testing-workers-in-cloudflare-workers/
As an interim solution, maybe some almost e2e tests, like a CLI SXG generator and a shell script that pipes it to dump-signedexchange -verify
.
Plus wrangler build
and the fastly_compute equivalent.
I'm thinking at a minimum the test plan should be a matrix of:
Accept header:
- prefers SXG
- doesn't prefer SXG
Response:
- small (<8MB) HTML
- small HTML +
<meta charset=utf-8>
- small HTML +
<meta charset=utf-8>
+ UTF-16 encoding with BOM - large (>8MB) HTML +
<meta charset=utf-8>
- small non-HTML
- large non-HTML
Another possible alternative to wrangler dev
is Cloudflare's Miniflare which is a local Workers emulator.