Isolate units with mocks, stubs, and spies. Mock external dependencies so tests don't depend on APIs, databases, or other services.
class UserRepository {
getUser(id) { /* database call */ }
}
class UserService {
constructor(repo) { this.repo = repo; }
// ...Isolate units with mocks, stubs, and spies. Mock external dependencies so tests don't depend on APIs, databases, or other services.
class UserRepository {
getUser(id) { /* database call */ }
}
class UserService {
constructor(repo) { this.repo = repo; }
// ...