Do you want to request a feature or report a bug?
Bug
What is the current behavior?
If I run npm test which is "test": "jest -u" it creates folder jest_0 which contains jest-transform-cache-... dir and other files. But with yarn test everything is alright, so I don't know if it's NPM or Jest problem.

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.
Everything is described above.
What is the expected behavior?
With npm test which runs jest -u to don't create jest_0 folder like Yarn do.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
OS: Linux Ubuntu 16.04
Node: 7.9.0
NPM: 4.6.1
Yarn: 0.24.4
Jest: 20.0.1
Also it creates v8-compile-cache-0 folder.
Seems Yarn create v8-compile-cache-0 folder too.
What's the output of jest --showConfig?
When I run jest through npm inside docker I get this path "cacheDirectory": "/usr/src/app/jest_0" which explains why it saves the cache there. If I just execute the node /usr/src/app/node_modules/jest/bin/jest.js --showConfig it becomes /tmp/jest_0 which makes sense. I wonder why running through npm causes it to use that for cacheDirectory
It seems to be an old npm issue npm/npm#4531
To work around I defined a explicit cache directory on jest config:
"cacheDirectory": "./node_modules/.cache/jest"
@terlar does it also work for you by updating NPM?
I can't repro it with this Dockerfile
FROM node:7.7-alpine
WORKDIR /app
RUN yarn add jest
I built it docker build . -t jest-config-bug.
And then did
docker run -it jest-config-bug node_modules/.bin/jest jest --showConfig
and
docker run -it jest-config-bug yarn jest -- --showConfig
They both show "cacheDirectory": "/tmp/jest_0"
@rogeliog The problem was specifically with npm so your test with yarn does not really test the case.
See this for minimal reproducible setup:
package.json
{
"name": "jest-config-bug",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest --showConfig"
},
"author": "",
"license": "ISC",
"dependencies": {
"jest": "^20.0.4"
}
}
Dockerfile
FROM node:7.7-alpine
WORKDIR /app
COPY package.json /app
RUN npm install
Build:
docker build . -t jest-config-bug
And test with:
docker run -it jest-config-bug npm test
This is an npm "feature", see npm/npm#4531 (as linked above) for workarounds.
Most helpful comment
It seems to be an old npm issue npm/npm#4531
To work around I defined a explicit cache directory on jest config: