run browser tests or scripts within an emulated DOM
This library is intended to run any script from NodeJs inside an emulated DOM provided by jsdom.
Script is read from standard input and results are displayed to standard output or standard error by connecting the jsdom
console to NodeJs console.
For example Tape results are directed to stdout. Any test library or script writing to the console should work.
test.js:
var test = require('tape');
test('demo', function (t) {
t.equal(1+1, 2)
t.end()
})
Then build it and run the test:
browserify test.js | jsdom-runner
var runner = require('jsdom-runner')
Returns a writable stream. Pipe your js code into it.
pageOptions
: options forcreate-html
module, documentation is herejsdomOptions
: options for jsdom instance, documentation is here
npm install -g jsdom-runner
But --save-dev option should suffice!
- https://github.com/substack/testling (tests with the browser installed on your system)
- https://github.com/shama/testron (tests with Electron)
- https://github.com/rstacruz/jsdom-global (different approach, injects the DOM into the test)