Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
90 changed files
with
1,187 additions
and
824 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# expect.addStyle(...) | ||
|
||
Install a single [MagicPen](https://github.com/sunesimonsen/magicpen) style into the | ||
`expect` instance, so that it's used when rendering error messages and diffs. | ||
|
||
Proxies through to [magicPen.addStyle](https://github.com/sunesimonsen/magicpen#addstylestyle-handler). | ||
See the documentation there. | ||
|
||
Example: | ||
|
||
```js | ||
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[i % rainbowColors.length]; | ||
this.text(text[i], color); | ||
} | ||
}); | ||
|
||
expect('foobar', 'to equal', 'foo bar'); | ||
``` | ||
|
||
```output | ||
expected 'foobar' to equal 'foo bar' | ||
-foobar | ||
+foo bar | ||
``` |
Oops, something went wrong.