Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not watch any files in run mode #4458

Merged
merged 2 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/server/lib/project.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand Down
10 changes: 10 additions & 0 deletions packages/server/test/integration/cypress_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
14 changes: 10 additions & 4 deletions packages/server/test/unit/project_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down