Write code that can be tested:
// Hard to test (hidden dependency)
function getPrice() {
return fetchBasePrice() * 1.1;
}
// Testable (explicit dependency)
function getPrice(basePrice) {
return basePrice * 1.1;
}
Pass dependencies as parameters. Avoid global state. Keep functions focused on one task.