testing
Technical notes on web development, DevOps, and AI integration.
83 articles
- 22:36testing
First Day With Vitest, and It Immediately Exposed Two Bugs
A Next.js frontend got its first vitest suite: 12/12 green, yet two bugs surfaced while writing the tests, before they could become complaints.
TL;DR: Installed Vitest on a Nextjs frontend that had no tests and wrote twelve passing checks. Writing them revealed two hidden issues, a client name duplicated across industry groups and a token gate whose glob missed files directly under src. The takeaway is to add a test harness early, since building tests finds bugs even when everything stays green.
#vitest#testing#git - 19:55testing
When the Test Reads Its Own Source Code
Vitest refuses to render components under Vite 8? Make the source files the test data: lock the rating flag invariant with toContain.
TL;DR: Vitest could not transform JSX after Vite 8 moved to rolldown and oxc without a React plugin, breaking the entity card render test. Instead the author added a text tripwire that reads source files and asserts rating_enabled !== false on six surfaces. It checks code shape not runtime, so integration tests verify the flag gates display without leaking rating data.
#vitest#testing#react - 15:07backend
Three Nullable Shapes in a Go Write Path
Threading nullable columns through a Go CRUD: the PUT idiom, plain bools, a pointer ID, and an explicit null contract.
TL;DR: KotaPortal’s upsert adds four fields via three patterns: contact person uses empty-string-means-null, two booleans are always required, and type ID uses a nil pointer for null. PUT does a full overwrite, while responses avoid omitempty to ensure nulls appear explicitly for generated clients. New checks cap contact data at 100 characters and require type ID to be at least one.
#golang#api#mysql - 14:21backend
A Test That Passes by Day and Fails at Dawn
A date filter test failed every dawn from midnight to seven: two clocks in one test. Fix: derive dates from the database clock, pin midday.
TL;DR: A scheduled test failure came from two clocks: Go on a WIB host and MySQL in UTC, seven hours apart. Around midnight their dates diverged, so Go's yesterday still contained the database's today and assertions failed until morning. The fix uses MySQL's CURDATE as the single witness and pins rows to midday to stay clear of boundary drift.
#go#mysql#testing - 13:27testing
The Test That Counts Requests, Not Pixels
A Playwright test that intercepts network traffic to prove a form blocks submission client-side, plus a date-filter edge case that almost slipped through.
TL;DR: The test checks that submitting without a service pillar shows an inline error and sends no network request, verified via Playwright route interception. It fills all other fields and handles dev-only login plus a required phone setup wizard beforehand. It also adds coverage for a date filter edge case, ensuring today-to-today includes today using an exclusive bound the next day.
#playwright#testing#e2e - 10:21devops
A Dev Quick Login That Never Becomes a Backdoor
Automating development login through the real form submit plus a fail-closed env guard: fast, with no backdoor left behind in production.
TL;DR: Repeated manual logins for testing were exhausting, and injecting tokens to bypass the form broke app state and caused flaky tests. Instead, automating the actual form submission behind an explicit opt-in env variable keeps it off by default. Paired with role-limited dev users and separate config, it speeds up testing without opening security holes in production.
#security#authentication#testing - 10:44testing
The Guard That Says No and the Migration Road Home
A test-only commit: proving the global guard via httptest, and the migration down path on MySQL 5.7 really goes backward, then comes home.
TL;DR: We finally tested two long-ignored paths: the RequireGlobalBidang guard that should block bidang access and the down migrations that had never run. A table-driven unit test now locks in the guard's behavior, including its intentional fail-open for empty contexts. An integration test migrates down to version 56 and back up, verifying columns disappear and reappear correctly.
#go#testing#mysql - 08:17testing
Admin E2E: Testing Role and Bidang Guards Through the UI
Three Playwright specs for the admin area: login through the real UI, CRUD down to permanent delete with API verification, and role/bidang guards tested up to the server's 403.
TL;DR: We moved admin E2E tests beyond happy paths to guardrails, logging in via UI and reusing the localStorage token. It covers full CRUD in the Tiptap editor and trash flow, verifying permanent deletes via API not just UI. It also validates authorization, hiding user management from editors and blocking bidang users with a 403.
#playwright#e2e#testing - 07:27testing
When the Migration Table Lies in Bidang Integration Tests
Green suite, stale schema: schema_migrations only logs executed files, a leftover Docker volume quietly carries the old schema.
TL;DR: Tests stayed green after adding the bidang column because a stale MySQL volume kept the old schema while the migration version looked current. With no new files to run, the migrator did nothing and left the mismatch invisible. Now volumes are wiped before integration runs so migrations rebuild a fresh schema and six bidang scope scenarios are reliably verified.
#go#mysql#testing