From a389a51e45dc0bf708da304346079c3b6638caad Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Thu, 13 Jun 2019 12:54:57 -0400 Subject: [PATCH 1/2] do not watch pluginsFile in run mode --- packages/server/lib/project.coffee | 4 ++-- packages/server/test/unit/project_spec.coffee | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/server/lib/project.coffee b/packages/server/lib/project.coffee index 41ef0a666198..62e0f260484c 100644 --- a/packages/server/lib/project.coffee +++ b/packages/server/lib/project.coffee @@ -184,7 +184,7 @@ class Project extends EE watchPluginsFile: (cfg, options) -> debug("attempt watch plugins file: #{cfg.pluginsFile}") - if not cfg.pluginsFile + if not cfg.pluginsFile or options.isTextTerminal return Promise.resolve() fs.pathExists(cfg.pluginsFile) @@ -206,7 +206,7 @@ class Project extends EE watchSettings: (onSettingsChanged) -> ## bail if we havent been told to - ## watch anything + ## watch anything (like in run mode) return if not onSettingsChanged debug("watch settings files") diff --git a/packages/server/test/unit/project_spec.coffee b/packages/server/test/unit/project_spec.coffee index ebcbf1d20034..e2059b00bdbc 100644 --- a/packages/server/test/unit/project_spec.coffee +++ b/packages/server/test/unit/project_spec.coffee @@ -380,22 +380,28 @@ describe "lib/project", -> it "does nothing when {pluginsFile: false}", -> @config.pluginsFile = false - @project.watchPluginsFile(@config).then => + @project.watchPluginsFile(@config, {}).then => expect(@project.watchers.watchTree).not.to.be.called it "does nothing if pluginsFile does not exist", -> fs.pathExists.resolves(false) - @project.watchPluginsFile(@config).then => + @project.watchPluginsFile(@config, {}).then => + expect(@project.watchers.watchTree).not.to.be.called + + it "does nothing if in run mode", -> + @project.watchPluginsFile(@config, { + isTextTerminal: true + }).then => expect(@project.watchers.watchTree).not.to.be.called it "watches the pluginsFile", -> - @project.watchPluginsFile(@config).then => + @project.watchPluginsFile(@config, {}).then => expect(@project.watchers.watchTree).to.be.calledWith(@config.pluginsFile) expect(@project.watchers.watchTree.lastCall.args[1]).to.be.an("object") expect(@project.watchers.watchTree.lastCall.args[1].onChange).to.be.a("function") it "calls plugins.init when file changes", -> - @project.watchPluginsFile(@config).then => + @project.watchPluginsFile(@config, {}).then => @project.watchers.watchTree.firstCall.args[1].onChange() expect(plugins.init).to.be.calledWith(@config) From 93c84a9aaeed82408e5b585988496cf00af4eecf Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Thu, 13 Jun 2019 18:11:14 -0400 Subject: [PATCH 2/2] add integration test ensuring watchers aren't applied in run mode --- packages/server/test/integration/cypress_spec.coffee | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/server/test/integration/cypress_spec.coffee b/packages/server/test/integration/cypress_spec.coffee index 5da658fa2ff1..5488ed7c873e 100644 --- a/packages/server/test/integration/cypress_spec.coffee +++ b/packages/server/test/integration/cypress_spec.coffee @@ -329,6 +329,16 @@ describe "lib/cypress", -> expect(browsers.open).to.be.calledWithMatch(ELECTRON_BROWSER, {url: "http://localhost:8888/__/#/tests/integration/test2.coffee"}) @expectExitWith(0) + it "does not watch settings or plugins in run mode", -> + watch = sinon.spy(Watchers.prototype, "watch") + watchTree = sinon.spy(Watchers.prototype, "watchTree") + + cypress.start(["--run-project=#{@pluginConfig}"]) + .then => + expect(watchTree).not.to.be.called + expect(watch).not.to.be.called + @expectExitWith(0) + it "scaffolds out integration and example specs if they do not exist when not runMode", -> config.get(@pristinePath) .then (cfg) =>