liveBook · Manning

Integration test

As explained in Build AI-Enhanced Web Apps

Integration testing evaluates interactions and data exchange among multiple software components, application boundaries, or external services.

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

How Build AI-Enhanced Web Apps covers it

How deep it goes
Defines the test boundary and gives workflow examples, but does not provide a complete integration-test implementation.
Examples
Uses an LLM-backed API route and a LangChain.js document-summarization workflow as test scenarios.
What it assumes
Assumes familiarity with React or Next.js application components; distinguishes integration tests from isolated unit tests.
What you can do after
Practice/perform integration checks that verify requests, responses, and interactions when application features change.
How it connects
Connects unit testing, API routes, mocking, LLM responses, and LangChain.js workflows.

Also explained in

Compare how 31 books explain integration test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI-Enhanced Web Apps. The section links point to the parts of the book it draws on.