Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can delay the Jest setup until the execution of the Docker Compose command by using the wait-for-it script in your Jest configuration file.

Here's an example of how to set this up:

  1. Install the wait-for-it script by following the instructions in the GitHub repository: https://github.com/vishnubob/wait-for-it
  2. Update your Jest test script to include the wait-for-it script before starting the tests. For example:
"scripts": {
  "test": "wait-for-it.sh <database-host>:<database-port> --timeout=60 && jest"
}
  1. Before running the Jest tests, start the Docker Compose services using the docker-compose up command. This will ensure that the services are running and available before running the tests.