testing

System test: asserting Turbo Stream responses

I don’t test Hotwire behavior by guessing; I add system tests that exercise the UI. With Capybara, I click a button that triggers a Turbo Stream response and assert that the DOM changes without a full page reload. The exact assertion depends on the fe

Integration tests in tests/ directory

Integration tests go in the tests/ directory and are compiled as separate binaries. Each file in tests/ is a separate test crate with access only to your crate's public API. This enforces API-level testing and catches issues that unit tests miss. I us

Unit testing with JUnit and MockK

Unit testing verifies individual components in isolation. I use JUnit 5 or JUnit 4 as the test framework with @Test annotations. MockK provides Kotlin-friendly mocking—mockk<T>() creates mocks, every { } stubs behavior, verify { } confirms calls

Unit tests with #[test] and assert macros

Rust's built-in test framework is simple and powerful. Mark functions with #[test], and cargo test runs them. Use assert!, assert_eq!, and assert_ne! for assertions. Tests live alongside code in the same file, typically in a #[cfg(test)] mod tests blo

Table-driven tests for HTTP handlers with httptest

Go’s table-driven tests are one of the best “boring but effective” practices. For handlers, I use httptest.NewRecorder and httptest.NewRequest so tests run fast without networking. Each case specifies method, path, body, expected status, and sometimes

Testing Express routes with Supertest + Jest

Route tests give me fast feedback about the API contract without needing a full browser. I structure the app so I can import an app instance without binding a port, then use supertest to make requests. The key detail is determinism: stub time and rand

tempfile for safe temporary file creation

The tempfile crate creates temporary files and directories that are automatically cleaned up on drop. I use it in tests, build scripts, and anywhere I need scratch space. tempfile::NamedTempFile gives you a file path, while tempfile::tempfile() create

Rails fixtures vs factories for test data

Fixtures and factories both create test data, but suit different needs. Fixtures load YAML files into the database before tests, providing fast, consistent data. I use fixtures for static reference data like countries or categories. Factories (via Fac

Database testing strategies and fixtures

Database testing ensures schema and queries work correctly. I use transactions for test isolation—rollback after each test. Test fixtures provide consistent data. Factory patterns generate test data programmatically. Understanding schema migrations in

MSW for frontend API mocking in tests

Brittle test suites often come from mocking fetch at every call site. MSW lets me mock at the network layer: components make real HTTP calls, but the test environment intercepts them and returns deterministic responses. That keeps tests closer to real

React Testing Library for component tests

Testing Library encourages testing components from the user's perspective rather than implementation details. I query elements by accessible labels, text content, or roles—not by CSS classes or test IDs. User interactions use userEvent to simulate rea

Playwright smoke test for auth flow

When auth breaks in the UI, it’s expensive and it always seems to happen at the worst time. I keep one or two Playwright smoke tests that cover the critical path: login, navigate, create something, logout. The goal isn’t to test every edge case; it’s