A test can pass with fake data and still miss a problem with a real database, file, or network. An integration test checks behavior while leaving some dependencies real. It can look like a unit test: call a production function and check its result. The distinction is that a unit test keeps its dependencies in memory and controls their behavior, while an integration test may rely on systems or conditions outside the test’s control. section 1.11 section 10.1.3
A test enters integration-testing territory when it depends on things such as:
- A real database, filesystem, REST API, or network. section 1.8
- The real system clock, if changing time can change the result. section 1.8
- A database, network, or deployment being available for the test to run. section 1.7.2
Checking a website
A network-dependent test might await `isWebsiteAliveWithAsyncAwait()` and assert that the result has `success === true` and `status === "ok"`. Using `async` and `await` makes the assertions easier to read than a callback with `done()`. It does not turn the test into a unit test: the network call remains real. section 6.1.1 section 6.1.3
Figure 1.7 You can have many failure points in an integration test. All the units have to work together, and each could malfunction, making it harder to find the source of a bug.
The figure shows why a failed integration test can take longer to debug: any of several cooperating units could be responsible. section 1.8
That broader check is useful, but it costs something. Real dependencies can make tests slower, less predictable, and harder to set up. A failed website check, for example, could reflect application code, network conditions, a firewall, or the external website. Negative cases such as a network outage are also harder to simulate. Passing integration tests add confidence that code works with dependencies it does not control; they do not identify every fault precisely. section 6.1.4 section 10.1.3
Keep fast, dependable unit tests separate from integration tests so a flaky external check does not make every failure easy to dismiss. Run the broader checks as part of an automated testing strategy, alongside lower-level tests rather than instead of them. Before refactoring hard-to-test legacy code, a few integration tests can record existing behavior. After refactoring, replace most of those broad checks with smaller, more maintainable unit tests. section 7.4.3 section 12.3 section 12.4







































