browser-js-env
Calling local browser to run some js code and return the result to you. You can use both nodeJs interfaces or CLI interfaces.
Table of Contents
Features
- Run js code in browser, get results, can be async.
- Easy to run js code in different browsers.
- Make ajax easy to test.
Installation
npm i browser-js-env --save
Install on global
npm i browser-js-env -g
Quick CLI Example
check cli options [show]
- run sample
$ ./node_modules/.bin/jsinbrowser -h
Usage: jsinbrowser
-c [js code]
-t [test directory, default is __test_in_browser_env__]
-k [keep window, default will close window]
-o [open template cmd for start a browser with url]
--clean [clean test directory after running js code]
Options:
-h, --help Show help [boolean]
cli quick start [show]
- run sample
$ ./node_modules/.bin/jsinbrowser --clean -c "module.exports=document.title;"
browser-js-env:test
Quick API Example
quick run [show]
let browserJsEnv = ;;
- run sample
$ node test.js
browser-js-env:test
support promise [show]
let browserJsEnv = ; ;
- run sample
$ node test.js
12
support commonJs (by using webpack) [show]
let browserJsEnv = ;;
- run sample
$ node test.js
/a/b/c
try using safari as a browser [show]
let browserJsEnv = ;;
- run sample
$ node test.js
10
try using electron as a browser [show]
const browserJsEnv = ;const electron = ;const proc = ; ;
- run sample
$ node test.js
browser-js-env:test
try using headless chrome [show]
const browserJsEnv = ;const proc = ; const chromeApp = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'; ;
- run sample
$ node test.js
200
License
browser-js-env is MIT licensed
Document was generated by docway.