question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timeout exceeded when trying to follow quick start example

See original GitHub issue

I have a working Electron app, and I just tried getting started with spectron following the example:

const Application = require('spectron').Application
const assert = require('assert')
const electronPath = require('electron')
const path = require('path')
let settingsPath = null

describe('Application launch', function () {
  this.timeout(10000)

  beforeEach(function () {
    this.app = new Application({
      path: electronPath,
      args: [path.join(__dirname, '..')]
    })
    return this.app.start()
  })

  afterEach(function () {
    if (this.app && this.app.isRunning()) {
      return this.app.stop()
    }
  })

  it('spawns the tray', function () {
    return this.app.client.getWindowCount().then(function (count) {
      assert.equal(count, 0)
    })
  })
})

npm test starts the app, and then after the timeout elapses, it prints:

$ npm test

> radiamagent@0.0.1 test path
> mocha



  Application launch
    1) "before each" hook for "spawns the tray"


  0 passing (10s)
  1 failing

  1) Application launch
       "before each" hook for "spawns the tray":
     Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (path\test\spec.js)

This happens no matter how long I set the timeout. I’ve noticed that console.log() functions will fire if I add them to the beforeEach() block, but not it(). And this happens on Windows and Mac. Any ideas?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:13

github_iconTop GitHub Comments

8reactions
cristiammercadocommented, Aug 20, 2019

After hours of tests, this is the configuration worked for me, exactly this part chromeDriverArgs: ['remote-debugging-port=9222']:

const Application = require('spectron').Application
const assert = require('assert')
const electronPath = require('electron') // Require Electron from the binaries included in node_modules.
const path = require('path')

describe('Application launch', function () {
    this.timeout(10000)

    beforeEach(function () {
        this.app = new Application({
            // Your electron path can be any binary
            // i.e for OSX an example path could be '/Applications/MyApp.app/Contents/MacOS/MyApp'
            // But for the sake of the example we fetch it from our node_modules.
            path: path.join(__dirname, '..', 'node_modules', '.bin', 'electron' + (process.platform === 'win32' ? '.cmd' : '')),

            // Assuming you have the following directory structure

            //  |__ my project
            //     |__ ...
            //     |__ main.js
            //     |__ package.json
            //     |__ index.html
            //     |__ ...
            //     |__ test
            //        |__ spec.js  <- You are here! ~ Well you should be.

            // The following line tells spectron to look and use the main.js file
            // and the package.json located 1 level above.
            args: [path.join(__dirname, '..')],
            env: {
                ELECTRON_ENABLE_LOGGING: true,
                ELECTRON_ENABLE_STACK_DUMPING: true,
                NODE_ENV: 'test'
            },
            waitTimeout: 10e3,
            requireName: 'electronRequire',
            chromeDriverLogPath: '../chromedriverlog.txt',
            chromeDriverArgs: ['remote-debugging-port=9222']
        })
        return this.app.start()
    })

    afterEach(function () {
        if (this.app && this.app.isRunning()) {
            return this.app.stop()
        }
    })

    it('shows an initial window', function () {
        return this.app.client.getWindowCount().then(function (count) {
            assert.equal(count, 1)
            // Please note that getWindowCount() will return 2 if `dev tools` are opened.
            // assert.equal(count, 2)
        })
    })
})
5reactions
tarikhagustiacommented, Jul 29, 2019

downgrade to “spectron”: “^6.0.0” fix myproblem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Timeout exceeded for HTTPS POST?
The system API that is being used is experiencing "timeout exceeded" errors when connecting to a SugarCRM REST API using HTTPS. The errors...
Read more >
How to Fix a Lock Wait Timeout Exceeded Error in MySQL
This blog post covers the implications of a MySQL InnoDB lock wait timeout error, how to deal with it, and how to track...
Read more >
mysql - Getting "Lock wait timeout exceeded; try restarting ...
To keep with the example of the OP, this should have worked: mysql> set autocommit=0;. mysql> update customer set account_import_id = 1; commit;....
Read more >
A Complete Guide to Timeouts in Node.js
The above example sets the server timeout to 5 seconds so that inactive connections (when no data is being transferred in either direction) ......
Read more >
How to Get to the Bottom of Network Timeout Issues
That concept is that this kind of problem occurs because the request exceeds the set timeout time, and this setting may come from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found