AhmedRaisi / Tarsho

A vibrant marketplace app for entrepreneurs to offer services, supporting local businesses with a user-friendly platform.
Other
5 stars 6 forks source link

Jest Setup File Not Found in Docker Container for CI Workflow #82

Open AhmedRaisi opened 11 months ago

AhmedRaisi commented 11 months ago

Issue Summary: We are integrating Jest unit tests into our CI/CD pipeline using GitHub Actions. The backend application needs to run within a Docker container to access a test database (testdb), similar to how it operates with the user database (userdb) in the main application. However, during the CI process, Jest is unable to find the jest.setup.js file, despite it being present in the ./tarsho/server directory and supposedly copied into the /usr/src/app directory inside the Docker container.

Environment: Node.js Version: v18.17.0 Docker Version: 3 CI Tool: GitHub Actions

Steps to Reproduce: CI workflow triggers on push/pull request events in GitHub. GitHub Actions workflow starts Docker container for backend service. Workflow executes npm test inside the Docker container.

Expected Behavior: Jest should be able to locate the jest.setup.js file inside the Docker container and run the unit tests as part of the CI pipeline.

Current Behavior: When the CI workflow executes npm test inside the Docker container, Jest fails with an error stating that jest.setup.js in the setupFilesAfterEnv option was not found. The error points to being /usr/src/app.

Relevant Details: The jest.setup.js file exists in the ./tarsho/server directory. The Docker Compose setup mounts the server directory to /usr/src/app. The issue appears specifically in the context of the CI workflow and not in local development setups.

Additional Context: This issue is crucial for ensuring that our CI pipeline correctly runs unit tests in an environment that mirrors our production setup.

AhmedRaisi commented 11 months ago

I am open to any solutions, I am still learning about CI and best practices. ANY help is appreciated!