---
title: "Leveraging Testcontainers for Complex Integration Testing in Mattermost Plugins"
description: "Mattermost replaced brittle mock-based plugin tests with Testcontainers-driven integration tests that spin up a Mattermost server, PostgreSQL on an internal Docker network, and optional API mock containers."
url: "https://swe.quest/articles/leveraging-testcontainers-for-complex-integration-testing-in-mattermost-plugins-3edaea4757026529"
canonical: "https://www.docker.com/blog/leveraging-testcontainers-for-complex-integration-testing-in-mattermost-plugins/"
source: "Docker"
published: "2024-10-08"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["testing","containers","go","javascript"]
---

# Leveraging Testcontainers for Complex Integration Testing in Mattermost Plugins

A post on [Docker](https://swe.quest/sources/docker.md), published 2024-10-08, 6 min read, Case study. Original: [https://www.docker.com/blog/leveraging-testcontainers-for-complex-integration-testing-in-mattermost-plugins/](https://www.docker.com/blog/leveraging-testcontainers-for-complex-integration-testing-in-mattermost-plugins/)

## Summary

Mattermost replaced brittle mock-based plugin tests with Testcontainers-driven integration tests that spin up a Mattermost server, PostgreSQL on an internal Docker network, and optional API mock containers. A custom Go module exposes helpers for plugin installation, DB access, the Go API client and admin operations, while Testcontainers for Node.js pairs with Playwright for UI-level tests. The approach is used for the AI Copilot plugin (mocked LLM API) and the MS Teams plugin (mocked Microsoft Graph), giving isolated, repeatable tests where teams choose per-test or shared container lifetimes.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [Containers](https://swe.quest/tags/containers.md) (Infrastructure)
- [Go](https://swe.quest/tags/go.md) (Languages)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- Docker basics ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))
- Go testing ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- integration testing concepts ([easy posts on Testing](https://swe.quest/tags/testing.md?difficulty=easy))

## Keywords

Testcontainers, Mattermost, Playwright, PostgreSQL, Docker, Microsoft Graph API

## Related posts

- [Functional tests with Testcontainers](https://swe.quest/articles/functional-tests-with-testcontainers-8e8bddfb01d0b1bc.md): Zalando Engineering · 2022-04-11 · Medium · 7 min read · Testing, Java & JVM, Containers
  Black-box functional tests for a Spring service can run against the service packaged as a Docker image, with PostgreSQL and other dependencies started as separate containers via Testcontainers.
- [Shift-Left Testing with Testcontainers: Catching Bugs Early with Local Integration Tests](https://swe.quest/articles/shift-left-testing-with-testcontainers-catching-bugs-early-with-local-f90241b596ffcd90.md): Docker · 2025-03-13 · Medium · 10 min read · Testing, Developer productivity, PostgreSQL, TypeScript
  Running integration tests locally against real dependencies via Testcontainers catches bugs that unit tests and mocks miss, before code reaches shared CI or staging environments.
- [Test Your Database Without Mocks](https://swe.quest/articles/test-your-database-without-mocks-093131d18e46824a.md): Neon · 2025-01-15 · Medium · 7 min read · Testing, PostgreSQL, CI/CD
  Database mocks are brittle, expensive to maintain, and test little beyond the mock itself, since they skip real behaviour like transactions, isolation levels, foreign keys and referential integrity.
- [Streamlining Local Development with Dev Containers and Testcontainers Cloud](https://swe.quest/articles/streamlining-local-development-with-dev-containers-and-testcontainers-cloud-050962d8604171c1.md): Docker · 2024-08-27 · Medium · 7 min read · Containers, Testing, Developer tools, Java & JVM
  Testcontainers-based tests and services can run inside a dev container by giving the container Docker access, either through the Docker-in-Docker feature or by swapping in the Testcontainers Cloud feature, which runs an agent that points Docker calls at a remote cloud environment.
- [Why Testcontainers Cloud Is a Game-Changer Compared to Docker-in-Docker for Testing Scenarios](https://swe.quest/articles/why-testcontainers-cloud-is-a-game-changer-compared-to-docker-in-docker-for-206c0ecf09c497e2.md): Docker · 2024-11-14 · Medium · 8 min read · Testing, CI/CD, Containers
  Docker-in-Docker, commonly used to give CI jobs a Docker daemon for Testcontainers integration tests, requires privileged mode and nests storage drivers, cgroups and namespaces, which leads to security audit problems, flaky builds, slow pipelines and hard debugging.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
