-
Notifications
You must be signed in to change notification settings - Fork 55
Command Line Interface
YUI Test offers two command line options for JavaScript testing: one for Rhino and one for Node.js. These tools can be used to test command-line JavaScript in the same way that you use YUI Test for testing web-based JavaScript.
Note: The command line interface is not intended to test web-based JavaScript code. If your code ultimately runs in a browser, then it should be tested in a browser. The CLI is designed for testing CLI-based JavaScript only.
The Rhino CLI is found in javascript/build/yuitest/
and is named yuitest-rhino-cli.js
. To run the Rhino CLI, you must first download and install Rhino. Once installed, use the YUI Test Rhino CLI as follows:
java -jar js.jar yuitest-rhino-cli.js <yourfile> <yourfile> <yourfile>
You need to include all JavaScript files necessary for the tests to run except for the YUI Test JavaScript library. You can also pass directories to the CLI and it will recursively find and load all JavaScript files.
The Node.js CLI is directly installable using npm. Run the following on the command line to install YUI Test for Node.js:
npm install yuitest
If you want YUI Test to be available in all projects on your system, then install it using the global option:
npm install -g yuitest
After installation, you can use the Node.js CLI via:
yuitest <yourfile> <yourfile> <yourfile>
Inside the JavaScript file using YUI Test, make sure to include the following line:
var YUITest = require("yuitest");
This loads YUI Test into the current module and makes it available for use.
The options and usage for both CLIs are the same:
Usage: yuitest [options] [file|dir]*
Global Options
--groups groupname Run only tests cases that are part of groupname.
--help Displays this information.
--format <format> Specifies output format (junitxml tap xunit).
--verbose Display informational messages and warnings.
--webcompat Load tests designed for use in browsers.
The options are:
-
--groups
- specify comma-delimited groups of tests to run, such as--groups=core,assert
. -
--help
- displays the help screen. -
--format
- specifies the output format for the test results. Options arexunit
(default),junitxml
,json
,tap
, and `xml'. -
--verbose
- output additional debugging information to the console. -
--webcompat
- ensure thatYUITest
is a global object. This does not create a web testing environment.