Add a shared contract test for modules

Open
#1,576 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
65/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, node.js, typescript
Domain
backend, testing

Research direction

Start with the shared helper in packages/testcontainers/src/utils/test-helper.ts, then inspect existing module tests in packages/modules/*/src/*-container.test.ts to see how they create and connect to their containers. Add the contract invocation for each module using its existing test image and cover the listed shared behaviors. Done means every module runs the shared checks; some are expected to fail until the related fixes land.

Written by the indexing model from the issue text.

Description

maintenance patch

What happens

Each module tests its own happy path. Behaviour that every module should share is not tested per module, so regressions in it pass every suite:

  • starting the same builder twice
  • connecting after restart(), when the mapped ports have changed
  • withReuse() returning the same container, with the module's setup run once
  • a network alias being usable from another container
  • cleanup through await using
  • non-default credentials actually being applied

Expected

A shared contract test that each module runs against its own container:

describeModuleContract({
  create: () => new RedisContainer(IMAGE),
  connect: async (container) => {
    /* resolves when a client can use the container */
  },
});

Where

  • the shared helper in packages/testcontainers/src/utils/test-helper.ts, which modules may already import
  • one call in each packages/modules/*/src/*-container.test.ts

Notes

  • No new images: each module uses the image it already tests with.
  • Some checks will fail on main until the bugs they cover are fixed. Those are the red tests for the fixes.

Dependencies

  • Nothing blocks this. It can start now.
  • Coordinate with #1520, #1521: the start-twice and reuse checks are the failing tests for those fixes.
Dominant language
TypeScript
Stars
2.7k
Forks
290
Avg merge
4d 1h
Merged PRs (30d)
22

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from testcontainers/testcontainers-node

All issues in testcontainers/testcontainers-node

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.