Avner Levy
Avner Levy

Reputation: 6751

Lerna concurrency errors in Docker container

I have a typescript monorepo managed with Lerna. The tests are done with Jest.
There are tens of packages that have the test script defined, while the jest config is stored in a central location and used by all.
An example test script looks like this:

jest --config ../../../tests/jest.config.json --setupFiles ../../../tests/jest-setup.js --rootDir .

Each package has a different number of "../" depending on its location in the source folder tree.
It works 100% of the time on multiple platforms like Windows, Linux and Mac.
For some reason when we run it inside a docker container, if the concurrency isn't set to 1 we see jest process from one package getting actually the paramters of another one which cause it to fail:

@cmd/example-package: > @cmd/[email protected] test:integration
@cmd/example-package: > jest --config ../../tests/jest.config.json --setupFiles ../../tests/jest-setup.js --setupFilesAfterEnv ../../tests/setEnvVars.js --rootDir . --testPathPattern=./integration-tests --runInBand
@cmd/example-package: jest parameters: /src/cmd/example-package ,  --config,../../../tests/jest.config.json,--setupFiles,../../../tests/jest-setup.js,--setupFilesAfterEnv,../../../tests/setEnvVars.js,--rootDir,.,--testPathPattern=./integration-tests,--runInBand

The last line is printed from code added at the begining of the jest script which prints the current folder and the parameters passed. You can see that the parameters lerna reports passing to jest aren't the one which were actually used.
We saw such errors in the build process as well.
Any idea on how to solve it will be highly appriciated.

Upvotes: 0

Views: 151

Answers (1)

Avner Levy
Avner Levy

Reputation: 6751

In our case, the problem was related to the installation of a different version of the npm on top of the alpine node docker image in one of the container's base images.
Leaving the question here, in case it helps someone.

Upvotes: 0

Related Questions