An integration test checks whether parts of an application work together, rather than checking one component in isolation. In a React or Next.js AI application, the boundary might run from a user-facing component through an API route to a model response. The test should verify both the request sent across that boundary and the response the application handles. section 8.4.1
Choose a workflow, then test the interactions that matter:
- Exercise components or chains together. For a LangChain.js summarization workflow, check that the collaborating parts produce the expected result; reserve isolated function checks for unit tests. section 8.4.4
- Control external dependencies when a repeatable result is needed. Simulate model responses or document retrieval, but avoid mocking application code whose interaction the test is meant to verify. section 8.4.4 section 8.4.3
- Check failure paths as well as successful output: error handling, asynchronous operations, streaming behavior, and varying model outputs can affect the complete workflow. section 8.5
A model-backed API route
Call an API route that generates an LLM response. Verify that the application sends the intended request and handles the returned response. A controlled model response can make this check repeatable; testing against a small local LLM is closer to an integration test, but requires expectations that account for real model behavior. section 8.4.1 section 8.4.3
Add integration tests when adding features so the new behavior is checked against existing parts of the application. For the chat-testing project, run the supplied test cases with `npm run test -w ch08/chat-testing`; those tests do not require OpenAI or Google API keys. section 9.6.6 section 8.4.1






























