Color support!
Finally you can also assert the color of the text that is currently displayed in the terminal.
The Terminal
class has two new methods:
getStylesAt(line: number, char: number)
and
getStyledText()
getStylesAt
returns an array of all applied styles on the specified char. Of course, this method is type save and returns an array of AnsiStyleKind
which is exported by node-terminal-simulator
. Use this method to assert the color or other styles of the printed text.
getStyledText
returns a string that contains all the ANSI codes for styling. You can use this to print the string to the (real) terminal if you desire. I do not recommend using this method in unit testing.