Out NestJS tests are intermittently failing with “not enough memory” error being thrown. There is nothing really special about the tests except for the fact that it is growing as the project grows. It turns out a simple CLI parameter can mitigate the issue.
I’ve found the solution in CircleCI forum and the fix was to pass the parameter
-w 1 which effectively runs the test in a single thread.
# From yarn run test # To yarn run test -w 1
When I tried to run the test locally with the same command, the process takes a little more time to complete compared to the regular
yarn run test which is probably because it uses some form of parallel processing. Running it on single thread on CircleCI doesn’t have any impact on us at all and it even speed up the build process.