Console output

If you’re writing a custom reporter, there’s a good chance
you’ll want to print output to the console, whether that’s the browser’s
developer console or the stdout stream of a server-side process. In order to
make sure text-based reporters work on every supported platform, jstest
includes an API for writing to the console, no matter what environment your
tests are running on. If you use this API, your reporter will work on any
platform that jstest supports.

The console API is found on an object called JS.Console in the browser, or
require('jstest').Console on CommonJS platforms. It provides several sets
of methods for performing various tasks.

Text output

Console.puts(string) writes a string to the console, followed by a
newline. This will use the developer console in web browsers, the
runtime.trace() method on Adobe AIR, or the stdout stream on sever-side
platforms.

Console.print(string) writes the given string to the console, without a
trailing newline if the platform supports this. If not, the output is
buffered and will be flushed on the next puts() call.

Text formatting

The Console object supports the following methods for formatting text
output. Each method adds the named format to the current state, and all text
printed after calling the command will have that format applied.

In environments that do not support color formatting, these commands are
silently ignored.