Command line testing
You must first run grunt serve
.
Command lines must be run from the root of the gpf-js folder.
- With mocha:
http://localhost:8000/test/host/mocha/web.html
node test/host/mocha/nodejs.js
- Without mocha:
http://localhost:8000/test/host/web.html
node test/host/nodejs.js
phantomjs test/host/phantomjs.js
cscript /E:jscript test\host\cscript.js
java -jar node_modules\rhino-1_7r5-bin\rhino1_7R5\js.jar test\host\rhino.js
- With grunt:
- testing with PhantomJS (as a browser):
grunt connectIf mocha
grunt connectIf mocha:source
grunt connectIf mocha:debug
grunt connectIf mocha:release
- testing with NodeJS:
grunt mochaTest
grunt mochaTest:source
grunt mochaTest:debug
grunt mochaTest:release
- testing with cscript (Windows only):
grunt exec:testWscript
grunt exec:testWscriptVerbose
(alias:grunt wscript
)grunt exec:testWscriptDebug
grunt exec:testWscriptRelease
- testing with a simulated cscript environment (Non-windows):
grunt exec:testNodewscript
grunt exec:testNodewscriptVerbose
(alias:grunt nodewscript
)grunt exec:testNodewscriptDebug
grunt exec:testNodewscriptRelease
- testing with Rhino (java required):
grunt exec:testRhino
grunt exec:testRhinoVerbose
(alias:grunt rhino
)grunt exec:testRhinoDebug
grunt exec:testRhinoRelease
- testing with Nashorn (java required):
grunt exec:testNashorn
grunt exec:testNashornVerbose
(alias:grunt nashorn
)grunt exec:testNashornDebug
grunt exec:testNashornRelease
- testing with browsers using Selenium:
- you must first run
node detectSelenium
to check drivers installation (see below) grunt firefox
grunt chrome
grunt ie
grunt safari
- you must first run
- testing with PhantomJS (as a browser):
Selenium drivers
To enable browser automation with Selenium, a driver must be installed for most browsers. It is recommended to put them in the current PATH.
Please check selenium-webdriver documentation page.
Safari
Command line browser testing
Coming with version 0.1.7, it is now possible to test a specific browser using a command line.
There are several assumptions:
- The command line is spawned with only one parameter: the URL to open,
- The command line must remain active until the test is completed,
- When the test completes, the spawned process is closed with a SIGKILL signal.
To configure the command line:
- Make sure to run
grunt
at least once: this will initialize thetmp/config.json
file. - Open the
tmp/config.json
file, look for the"browsers"
part - For each browser you want to test, add a dictionary with
"type": "spawn"
and the binary path to the command line specified in the"bin"
property. Optionally, parameters that would be prepended before the testing URL might be specified with an array property"args"
For instance, Safari testing on Windows:
"browsers": {
"chrome": {
"type": "selenium"
},
"safari": {
"type": "spawn",
"bin": "C:\\Program Files (x86)\\Safari\\Safari.exe"
}
},