Skip to content

Commit

Permalink
fix desktop gui specs not being watched for file changes (#5934)
Browse files Browse the repository at this point in the history
* always null out specsWatcher so opening the project watches the specs for changes correctly

* add test, cleanup
  • Loading branch information
brian-mann authored and flotwig committed Dec 12, 2019
1 parent 5628fc3 commit 6e9e6ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/server/lib/open_project.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const preprocessor = require('./plugins/preprocessor')
const moduleFactory = () => {
let openProject = null
let relaunchBrowser = null
let specsWatcher = null

const reset = () => {
openProject = null
Expand All @@ -29,6 +28,8 @@ const moduleFactory = () => {
}

return {
specsWatcher: null,

reset: tryToCall('reset'),

getConfig: tryToCall('getConfig'),
Expand Down Expand Up @@ -165,21 +166,21 @@ const moduleFactory = () => {
250, { leading: true })

const createSpecsWatcher = (cfg) => {
if (specsWatcher) {
if (this.specsWatcher) {
return
}

debug('watch test files: %s in %s', cfg.testFiles, cfg.integrationFolder)

specsWatcher = chokidar.watch(cfg.testFiles, {
this.specsWatcher = chokidar.watch(cfg.testFiles, {
cwd: cfg.integrationFolder,
ignored: cfg.ignoreTestFiles,
ignoreInitial: true,
})

specsWatcher.on('add', checkForSpecUpdates)
this.specsWatcher.on('add', checkForSpecUpdates)

return specsWatcher.on('unlink', checkForSpecUpdates)
return this.specsWatcher.on('unlink', checkForSpecUpdates)
}

const get = () => {
Expand All @@ -205,9 +206,10 @@ const moduleFactory = () => {
stopSpecsWatcher () {
debug('stop spec watcher')

return Promise.try(() => {
return specsWatcher ? specsWatcher.close() : undefined
})
if (this.specsWatcher) {
this.specsWatcher.close()
this.specsWatcher = null
}
},

closeBrowser () {
Expand Down
11 changes: 11 additions & 0 deletions packages/server/test/unit/open_project_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe('lib/open_project', () => {
beforeEach(function () {
this.watcherStub = {
on: sinon.stub(),
close: sinon.stub(),
}

sinon.stub(chokidar, 'watch').returns(this.watcherStub)
Expand Down Expand Up @@ -141,5 +142,15 @@ describe('lib/open_project', () => {
expect(onChange).to.be.calledOnce
})
})

it('destroys and creates specsWatcher as expected', function () {
expect(openProject.specsWatcher).to.exist
openProject.stopSpecsWatcher()
expect(openProject.specsWatcher).to.be.null
openProject.getSpecChanges()
.then(() => {
expect(openProject.specsWatcher).to.exist
})
})
})
})

4 comments on commit 6e9e6ab

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6e9e6ab Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.0/win32-ia32/appveyor-develop-6e9e6ab3c60fa24caa5f364aa99ded73b2ad21f8-29504675/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.8.0/win32-ia32/appveyor-develop-6e9e6ab3c60fa24caa5f364aa99ded73b2ad21f8-29504675/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6e9e6ab Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.0/linux-x64/circle-develop-6e9e6ab3c60fa24caa5f364aa99ded73b2ad21f8-213813/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.0/circle-develop-6e9e6ab3c60fa24caa5f364aa99ded73b2ad21f8-213803/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6e9e6ab Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.0/win32-x64/appveyor-develop-6e9e6ab3c60fa24caa5f364aa99ded73b2ad21f8-29504675/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.8.0/win32-x64/appveyor-develop-6e9e6ab3c60fa24caa5f364aa99ded73b2ad21f8-29504675/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6e9e6ab Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.0/darwin-x64/circle-develop-6e9e6ab3c60fa24caa5f364aa99ded73b2ad21f8-213849/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.0/circle-develop-6e9e6ab3c60fa24caa5f364aa99ded73b2ad21f8-213809/cypress.tgz

Please sign in to comment.