CI your client side tests with Electron
This uses Electron to run tests in Chromium.
- Install to your project:
npm install testron --save-dev
- Install Electron:
npm install electron-prebuilt --save-dev
- Add a
test
script to yourpackage.json
:
{
"name": "my-project",
"scripts": {
"test": "testron test/client.js"
},
}
- Run
npm test
to run the test script in Electron
Currently this only supports TAP. Here is an example test written using tape:
var test = require('tape')
test('test this', function (t) {
t.plan(1)
var ul = document.createElement('ul')
var li = document.createElement('li')
ul.appendChild(li)
li.textContent = 'it works'
t.equal(ul.outerHTML, '<ul><li>it works</li></ul>')
t.end()
})
It is recommended bundling your tests and piping to testron
:
{
"name": "my-project",
"scripts": {
"test": "browserify test/client.js | testron"
},
}
Add a .travis.yml
file to your project:
language: node_js
node_js:
- 'iojs'
before_script:
- export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start
There is also an API:
var testron = require('testron')
var tests = testron('test/client.js')
tests.stdout.on('data', function (data) {
console.log('line: ' + data.toString())
})
tests.on('exit', function () {
console.log('Tests are done!')
})
These are similar projects that also (can) use Electron for testing:
(c) 2018 Kyle Robinson Young. MIT License