From 8e5ebb6a3966a3b3d6e118da57700941ddbf111b Mon Sep 17 00:00:00 2001 From: johnjbarton Date: Fri, 1 Jun 2018 10:04:23 -0700 Subject: [PATCH] fix(flaky-test): Add time to beforeEach() to allow plugins to load on first pass. Loading plugins in beforeEach seems unwise: the it() blocks potentially run against different environments. In particular the first it() block runs with the timer already worn down by the plugin load and often the timeout hits on my mac air before the test passes.Until we can restructure this code a longer timeout avoids flaky tests. --- test/unit/server.spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/unit/server.spec.js b/test/unit/server.spec.js index e5fdcc24f..04abbf381 100644 --- a/test/unit/server.spec.js +++ b/test/unit/server.spec.js @@ -17,7 +17,10 @@ describe('server', () => { var fileListOnResolve = fileListOnReject = mockLauncher = null var mockFileList = mockWebServer = mockSocketServer = mockExecutor = doneSpy = null - beforeEach(() => { + // Use regular function not arrow so 'this' is mocha 'this'. + beforeEach(function () { + // The first call to new Server() loads plugins and it can take >2000ms. + this.timeout(4000) browserCollection = new BrowserCollection() doneSpy = sinon.spy()