Skip to content

Commit

Permalink
try spectron
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jan 27, 2018
1 parent be9237a commit 98141db
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ dist
*.zip
coverage
.nyc_output
coverage.lcov
coverage.lcov
.cache
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@
"mocha": "^5.0.0",
"nyc": "^11.4.1",
"pre-commit": "^1.2.2",
"sinon": "^4.2.2"
"sinon": "^4.2.2",
"spectron": "^3.8.0"
},
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "eslint .",
"test": "cross-env NODE_ENV=test nyc --all mocha --require babel-core/register --require ./test/setup.js --recursive",
"test": "cross-env NODE_ENV=test mocha --require babel-core/register --require ./test/setup.js --recursive",
"coverage": "(nyc report --reporter=text-lcov > coverage.lcov) && codecov"
},
"nyc": {
Expand Down
37 changes: 37 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-env mocha */

import {expect} from 'chai'
import {Application} from 'spectron'
import path from 'path'
import {exec} from 'child_process'

const electron = path.resolve(__dirname, '../node_modules/.bin/electron')
const electronCompile = path.resolve(__dirname, '../node_modules/.bin/electron-compile')

describe('Application Launch', function () {
this.timeout(2 * 60 * 1000)
let app

beforeEach(() => new Promise((resolve, reject) => {
console.log('sart compiling')
exec(`${electronCompile} ${path.resolve(__dirname, '../')}`, () => {
console.log('compiled')
app = new Application({
path: electron,
args: [path.join(__dirname, '../src/index.js')]
})
console.log('app')
app.start().then(resolve)
})
}))

afterEach(() => {
if (app && app.isRunning()) {
return app.stop()
}
})

it('opens a window', () => {
return app.client.waitUntilWindowLoaded()
})
})

0 comments on commit 98141db

Please sign in to comment.