Spectron
- 3. Ruby ‑> JavaScript(Node) あるある
return を書かない
> hoge = function hoge() { "hogehoge" }
[Function: hoge]
> hoge()
undefined
- 6. OK : thisを渡す
convert() {
this.ary1.forEach(val => {
this.ary2.push(this.str2num(val))
}, this)
}
OK : Allow functionを使う(thisを語彙的に束縛する)
convert() {
this.ary1.forEach(val => {
this.ary2.push(this.str2num(val))
})
}
- 14. Electron App
your-app/
├── package.json
├── main.js
└── index.html
const { app, BrowserWindow } = require('electron')
function createWindow () {
win = new BrowserWindow({ width: 800, height: 600 })
win.loadFile('index.html')
}
app.on('ready', createWindow)
$ npm run start
- 20. Demo : npm runしてテストする
https://github.com/electron/spectron#usage
electronアプリを起動してWindowの数をテストするだけ
- 31. spectron‑fake‑menu example
describe('Increment', function() {
this.timeout(10000);
let app;
beforeEach(function() {
app = createApplication();
return app.start();
});
afterEach(function() {
return app.stop();
});
it('increment count', () => {
return app.client.waitForExist('#count')
.then(() => {
fakeMenu.clickMenu('Count', 'Increment');
return waitForChangeCount(app, '1');
})
.then(() => assert.ok(true));
});
});
- 45. Travis CI
### .travis.yml ###
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start