From 229c69ff387cdc11e0a59a6d9b1d406f6dc587de Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Sun, 4 Nov 2018 23:09:51 -0800 Subject: [PATCH] Attempt to fix possible race condition with sinon.spy --- test/_util.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/_util.js b/test/_util.js index c9a1c1af..5ef08617 100644 --- a/test/_util.js +++ b/test/_util.js @@ -31,11 +31,15 @@ test.after.always(t => { test.beforeEach(t => { t.context.workDir = tempy.directory() t.context.tempDir = tempy.directory() - sinon.spy(console, 'warn') + if (!console.warn.restore) { + sinon.spy(console, 'warn') + } }) test.afterEach.always(t => { - console.warn.restore() + if (console.warn.restore) { + console.warn.restore() + } return fs.remove(t.context.workDir) .then(() => fs.remove(t.context.tempDir)) })