Developer testing guide
Playwright and Cypress upload fixtures
Reliable upload tests separate fixture acquisition from UI behavior. Pin the URL, expected MIME, byte size, and SHA-256, then upload a local buffer so failures identify whether the network, fixture, or application changed.
Verified . Examples use current Playwright and Cypress buffer-upload APIs and stable TestFiles asset URLs.
Practical checklist
- Download fixtures during setup or commit a verified mirror.
- Assert status, MIME, byte size, and SHA-256.
- Upload with an explicit filename and MIME.
- Test the success UI and persistent server result.
Choose live or mirrored fixtures
Live URLs are convenient for examples and integration checks. For isolated CI, mirror the bytes in your repository or test bucket and keep the published SHA-256 as the integrity assertion.
Keep acquisition outside the UI step
Fetch and verify the buffer before opening the upload form. This prevents an unrelated fixture download outage from being reported as a selector or component failure.
Assert observable outcomes
After selecting the file, assert filename, preview or metadata, request result, stored record, and retry behavior. Do not stop at checking that an input contains a File object.
Expected results
- Fixture metadata matches the manifest before upload.
- The application receives the intended filename, MIME, and exact bytes.
- CI can switch between live and mirrored sources without changing UI steps.
Common failure modes
- Downloading mutable files during every UI assertion.
- Relying on a developer machine path.
- Skipping hash validation when a test requires exact bytes.
Check the fixture with curl
Download the representative file and print the response status, MIME type, and transferred byte count.
curl --fail --location --silent --show-error \
--output sample-document.pdf \
--write-out 'status=%{http_code}\ncontent_type=%{content_type}\nbytes=%{size_download}\n' \
'https://assets.testfiles.dev/documents/sample-document.pdf'Verify document integrity with Python Requests
Download the document and assert its MIME type, exact byte size, and SHA-256 digest before passing it to a parser or preview service.
import hashlib
import requests
url = "https://assets.testfiles.dev/documents/sample-document.pdf"
response = requests.get(url, timeout=30)
response.raise_for_status()
assert "application/pdf" in response.headers.get("content-type", "")
assert len(response.content) == 9051
assert hashlib.sha256(response.content).hexdigest() == "c0ca139748753dd192bda50ea731868e8f832b5ed97499d12ffb2c995791ffbc"
print("Verified sample-document.pdf", len(response.content), "bytes")Playwright fixture upload
Fetch a PDF through Playwright, verify its response, and upload the exact buffer.
import { test, expect } from '@playwright/test';
test('uploads a verified PDF fixture', async ({ page, request }) => {
const response = await request.get('https://assets.testfiles.dev/documents/sample-document.pdf');
expect(response.ok()).toBeTruthy();
const buffer = await response.body();
await page.getByLabel('File').setInputFiles({ name: 'sample-document.pdf', mimeType: 'application/pdf', buffer });
await expect(page.getByText('sample-document.pdf')).toBeVisible();
});Cypress fixture upload
Download binary bytes and pass them to selectFile with explicit metadata.
cy.request({ url: 'https://assets.testfiles.dev/documents/sample-document.pdf', encoding: 'binary' })
.then((response) => {
expect(response.status).to.eq(200);
const contents = Cypress.Buffer.from(response.body, 'binary');
cy.get('input[type=file]').selectFile({ contents, fileName: 'sample-document.pdf', mimeType: 'application/pdf' });
});Use stable sample files
These fixtures have stable URLs, recorded MIME types, byte sizes, SHA-256 values, and dedicated detail pages.