From ec4294d124e41cee8aad102b462f79f2739f90eb Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 8 May 2019 21:47:52 +0200 Subject: [PATCH 1/2] Avoid test collisions by using different directories in runInTempDirectory --- jest/runInTempDirectory.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jest/runInTempDirectory.js b/jest/runInTempDirectory.js index c6d025eb3..cddd8246c 100644 --- a/jest/runInTempDirectory.js +++ b/jest/runInTempDirectory.js @@ -3,10 +3,10 @@ import path from 'path' import rimraf from 'rimraf' -const tmpPath = path.resolve(__dirname, '../__tmp') - export default function(callback) { return new Promise(resolve => { + const timestamp = new Date().valueOf() + const tmpPath = path.resolve(__dirname, `../__tmp_${timestamp}`) const currentPath = process.cwd() rimraf.sync(tmpPath) From 11dfbdeaa8d3b47b2a53045036f21446e526d0cd Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Thu, 9 May 2019 13:29:48 +0200 Subject: [PATCH 2/2] Use `process.env.JEST_WORKER_ID` --- jest/runInTempDirectory.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jest/runInTempDirectory.js b/jest/runInTempDirectory.js index cddd8246c..025361045 100644 --- a/jest/runInTempDirectory.js +++ b/jest/runInTempDirectory.js @@ -5,8 +5,8 @@ import rimraf from 'rimraf' export default function(callback) { return new Promise(resolve => { - const timestamp = new Date().valueOf() - const tmpPath = path.resolve(__dirname, `../__tmp_${timestamp}`) + const workerId = process.env.JEST_WORKER_ID + const tmpPath = path.resolve(__dirname, `../__tmp_${workerId}`) const currentPath = process.cwd() rimraf.sync(tmpPath)