Casperjs API-colorizer Module
The colorizer module contains a Colorizer class that can generate a standardized color string: var colorizer = require ('colorizer '). create ('colorizer'); console. log (colorizer. colorize ("Hello World", "INFO"); in most cases, you will use it using the CASPER echo () method. Casper. echo ('an Ive message', 'info'); // printed in greencasper. echo ('an error message', 'error'); // printed in red ignores casperjs style options: if you do not need to set the color, you only need to set the colorizerType to Dummy: var casper = require ('casper '). create ({colorizerType: 'dummy'}); casper. echo ("Hello", "INFO"); note: this is especially useful if casperjs is used on Windows, color output of available predefined styles is not supported on windows platforms: available predefined styles include: ERROR: White Red Bottom INFO: green text TRACE: green text PARAMETER: cyan text COMM ENT: yellow text WARNING: red text GREEN_BAR: white text RED_BAR: white text INFO_BAR: blue text WARN_BAR: white text The following is an example: colorizer colorize () Signature: colorize (String text, String styleName) calculates the text String provided by a color version and uses a given predefined style: var colorizer = require ('colorizer '). create (); console. log (colorizer. colorize ("I'm a red error", "ERROR"); Note: you do not need to use a colorizer instance most of the time. casperjs provides all the necessary methods. Format () Signature: format (String text, Object style) format a String using the provided style. A style definition is a standard javascript Object with the following attributes: String bg: background color name String fg: foreground color name Boolean bold: the bold format Boolean underscore is applied: underline format Boolean blink: flashing format Boolean reverse: Apply reverse format Boolean conceal: Use a hidden format to indicate that the optional color names are black, red, green, yellow, blue, magenta, cyan and white: var colorizer = require ('colorizer '). create (); colorizer. format ("We all live in a yellow submarine", {bg: 'yellow', fg: 'blue', bold: true });