expect.addStyle(...)

Install a single MagicPen style into the expect instance, so that it's used when rendering error messages and diffs.

Proxies through to magicPen.addStyle. See the documentation there.

Example:

expect.addStyle('jsString', function(text, rainbowColors) {
  rainbowColors = rainbowColors || [
    'gray',
    'red',
    'green',
    'yellow',
    'blue',
    'magenta',
    'cyan'
  ];
  for (var i = 0; i < text.length; i += 1) {
    var color = rainbowColors[% rainbowColors.length];
    this.text(text[i], color);
  }
});
 
expect('foobar', 'to equal', 'foo bar');
expected 'foobar' to equal 'foo bar'
 
foobar
foo bar