0

Got a recent Requirement, where i need to do Test Automation of Backend Node js application using the spectron. I would like to know what are programming skills required to approach the same

Saran3g
  • 29
  • 5

1 Answers1

0

Find the Spectron documentation at https://electronjs.org/spectron

Installation

npm install --save-dev spectron

Sample test file looks like this

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

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('shows an initial window', function () {
    return this.app.client.getWindowCount().then(function (count) {
      assert.equal(count, 1)

    })
  })
})

Spectron can work with any test framework. I prefer using mocha.

Clone this project for more info https://github.com/electron/spectron

Bharath Kumar S
  • 1,410
  • 2
  • 10
  • 29